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

dev_forum
jingquan huang 5 years ago
commit c31c07b453

@ -284,7 +284,7 @@ class CoursesController < ApplicationController
@is_admin = @user_course_identity < Course::PROFESSOR
@applications= CourseMessage.unhandled_join_course_requests_by_course(@course)
@applications = @is_admin ? CourseMessage.unhandled_join_course_requests_by_course(@course) : CourseMessage.none
page = params[:page] || 1
limit = params[:limit] || 20
@ -548,6 +548,7 @@ class CoursesController < ApplicationController
course_teacher = CourseMember.find_by(user_id: current_user.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR], course_id: @course.id)
course_student.destroy!
course_teacher.update_attributes(is_active: 1) if course_teacher.present? && !course_teacher.is_active
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [current_user.id])
normal_status(0, "退出成功")
end
@ -684,11 +685,16 @@ class CoursesController < ApplicationController
ActiveRecord::Base.transaction do
begin
students = params[:students]
student_ids = []
students.each do |student|
course_member = CourseMember.find_by!(id: student[:course_member_id].to_i, course_id: @course.id)
course_member = CourseMember.find_by(id: student[:course_member_id].to_i, course_id: @course.id)
if course_member.present?
student_ids << course_member.user_id
course_member.destroy!
end
end
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, student_ids) if student_ids.present?
normal_status(0, "操作成功")
rescue => e
uid_logger(e.message)
@ -711,7 +717,7 @@ class CoursesController < ApplicationController
student_ids = []
user_ids.each do |user_id|
existing_course_member = CourseMember.find_by(user_id: user_id.to_i, course_id: @course.id)
existing_course_member = @course.course_members.find_by(user_id: user_id.to_i)
new_student = CourseMember.new(user_id: user_id.to_i, course_id: @course.id, course_group_id: course_group_id, role: 4)
if existing_course_member.present?
@ -720,6 +726,7 @@ class CoursesController < ApplicationController
else
new_student.is_active = 0 if existing_course_member.is_active
new_student.save!
student_ids << user_id
end
else
new_student.save!
@ -727,6 +734,7 @@ class CoursesController < ApplicationController
end
end
CourseAddStudentCreateWorksJob.perform_later(@course.id, student_ids) if student_ids.present?
TeacherInviteJoinCourseNotifyJob.perform_later(current_user.id, @course.id, 10, student_ids) if student_ids.present?
normal_status(0, "添加成功")
rescue => e
@ -868,6 +876,7 @@ class CoursesController < ApplicationController
new_student.course_group_id = course_group.id if course_group.present?
new_student.save!
CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id)
end
end

@ -10,13 +10,13 @@ class DiscussesController < ApplicationController
if current_user.admin?
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
@discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s,
:root_id => nil).includes(:user, :praise_tread).offset(offset)
:root_id => nil).includes(:user, :praise_treads).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: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id})
@disscuss_count = disscusses.count
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset)
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_treads).offset(offset)
end
@current_user = current_user

@ -32,38 +32,34 @@ class ExercisesController < ApplicationController
@exercises_all = @course.exercises
member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷
@current_user_ = current_user
@exercises_count = @exercises_all.size # 全部页面,需返回
@exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数
@exercises_published_counts = @exercises_all.exercise_by_status([2,3]).size # 已发布的试卷数,包含已截止的
@exercises_ended_counts = @exercises_all.exercise_by_status(3).size #已截止的试卷数
# 课堂的学生人数
@course_all_members = @course.students #当前课堂的全部学生
@course_all_members_count = @course_all_members.size #当前课堂的学生数
@current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生
# exercises的不同用户群体的显示
if @user_course_identity < Course::STUDENT # @is_teacher_or 1为老师/管理员/助教
@is_teacher_or = 1
# @teacher_groups_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?)
@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 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的)
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : []
@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.present? ?
@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.present? ? member_show_exercises.unified_setting : []
@exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
end
if @exercises.size > 0
if params[:type].present?
choose_type = params[:type].to_i
@ -74,12 +70,12 @@ class ExercisesController < ApplicationController
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.present? ?
@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.present? ?
@exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(3).unified_setting
.or(@exercises_all.where(id: exercise_ended_ids))
: []
@ -106,6 +102,11 @@ class ExercisesController < ApplicationController
@exercises = []
end
@course_all_members_count = @course_all_members.size #当前课堂的学生数
@exercises_count = @exercises_all.size # 全部页面,需返回
@exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数
@exercises_published_counts = @exercises_count - @exercises_unpublish_counts # 已发布的试卷数,包含已截止的
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
@ -477,10 +478,8 @@ class ExercisesController < ApplicationController
params_end_time = params[:end_time].to_time
end
if exercise_status == 2 && @exercise.publish_time != params_publish_time
normal_status(-1,"已发布,不允许修改发布时间")
elsif exercise_status == 3 && (@exercise.end_time != params_end_time || @exercise.publish_time != params_publish_time)
normal_status(-1,"已截止,不允许修改时间")
if (exercise_status != 1) && (@exercise.publish_time != params_publish_time)
normal_status(-1,"已发布/已截止,不允许修改发布时间")
elsif params_publish_time.present? && params_end_time.present? && params_end_time < params_publish_time
normal_status(-1,"截止时间不能小于发布时间")
else
@ -523,12 +522,7 @@ class ExercisesController < ApplicationController
end
# exercise_end_time = t[:end_time].present? ? t[:end_time].to_time : nil
exercise_group = exercise_groups.find_in_exercise_group("course_group_id",course_id) #判断该分班是否存在
if exercise_group.present? && exercise_group.first.end_time <= Time.now &&
(exercise_end_time != exercise_group.first.end_time || exercise_publish_time != exercise_group.first.publish_time) #已截止且时间改变的,则提示错误
error_count += 1
end
if exercise_group.present? && exercise_group.first.publish_time <
Time.now && exercise_publish_time != exercise_group.first.publish_time
if exercise_group.present? && (exercise_group.first.publish_time < Time.now) && (exercise_publish_time != exercise_group.first.publish_time)
error_count += 1
end
if error_count == 0
@ -1300,7 +1294,9 @@ class ExercisesController < ApplicationController
if params[:format] == "xlsx"
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
elsif (@exercise_status == 1) || (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
elsif @exercise_status == 1
normal_status(-1,"试卷未发布")
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
normal_status(-1,"暂无用户提交")
else
respond_to do |format|
@ -1637,35 +1633,8 @@ class ExercisesController < ApplicationController
@answer_committed_user = @exercise.exercise_users.exercise_commit_users(current_user.id)&.first
if @answer_committed_user.blank?
normal_status(404,"答题用户不存在")
# elsif @exercise.get_exercise_status(current_user.id) == 2 && @answer_committed_user.commit_status == 1 #当试卷截止时,会自动提交
# normal_status(-1,"提交错误,试卷用户已提交!")
end
end
# def commit_user_exercise
# @exercise_user_current = @exercise.exercise_users.exercise_commit_users(@exercise_current_user_id)&.first #查找当前用户是否有过答题
# if @user_course_identity == Course::STUDENT
# if @exercise_user_current.present?
# if @exercise.time > 0 && @exercise_user_current.start_at.present? && (@exercise_user_current.commit_status == 0) &&
# ((@exercise_user_current.start_at + (@exercise.time.to_i + 1).minutes) < Time.now)
# #当前用户存在,且已回答,且试卷时间已过,且未提交,则自动提交。最好是前端控制
# objective_score = calculate_student_score(@exercise,current_user)[:total_score]
# subjective_score = @exercise_user_current.subjective_score < 0.0 ? 0.0 : @exercise_user_current.subjective_score
# total_score = objective_score + subjective_score
# commit_option = {
# :status => 1,
# :commit_status => 1,
# :end_at => Time.now,
# :objective_score => objective_score,
# :score => total_score,
# :subjective_score => subjective_score
# }
# @exercise_user_current.update_attributes(commit_option)
# normal_status(0,"已交卷成功!")
# end
# end
# end
# end
end
end
#打回重做时的初步判断
def check_exercise_status

@ -23,8 +23,8 @@ class FilesController < ApplicationController
get_category(@course, course_second_category_id)
@total_count = @attachments.size
@public_count = @attachments.publiced.size
@private_count = @total_count - @public_count
@publish_count = @attachments.published.size
@unpublish_count = @total_count - @publish_count
@attachments = @attachments.by_keywords(params[:search])
@attachments =

@ -40,10 +40,8 @@ class GamesController < ApplicationController
next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position)
# 关卡点赞数, praise_or_tread = 1则表示赞过
praise_count = PraiseTread.where(praise_tread_object_id: game_challenge.id, praise_tread_object_type: "Challenge",
praise_or_tread: 1).count
user_praise = PraiseTread.where(praise_tread_object_id: game_challenge.id, praise_tread_object_type: "Challenge",
user_id: current_user.id, praise_or_tread: 1).present? ? true : false
praise_count = game_challenge.praises_count
user_praise = game_challenge.praise_treads.exists?(user_id:current_user.id, praise_or_tread: 1)
# 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集
max_query_index = @game.query_index.to_i
@ -221,12 +219,12 @@ class GamesController < ApplicationController
@result = challenge.st == 0 ? challenge.try(:answer) : challenge.choose_answer
end
# 获取答案
# 获取实践题答案
# GET: /tasks/:identifier/get_answer_info
# 0 直接查看答案, 1 查看答案弹框, 2 答案详情弹框
def get_answer_info
challenge = @game.challenge
@challenge_answers = challenge.challenge_answers
@challenge = @game.challenge
@challenge_answers = @challenge.challenge_answers
# 平台已认证的老师需要控制
@power = (@identity < User::EDU_GAME_MANAGER)
if !@power
@ -243,16 +241,29 @@ class GamesController < ApplicationController
end
end
end
end
# 获取选择题答案
def get_choose_answer
@challenge = @game.challenge
tip_exception("本接口只能获取选择题答案") if @challenge.st != 1
@power = (@identity < User::EDU_GAME_MANAGER)
# 如果没权限,也没看过答案,则需要解锁
if @game.answer_open == 0 && !@power
tip_exception(1, @challenge.choose_score)
else
@challenge_chooses = @challenge.challenge_chooses
end
end
# 解锁答案
# 解锁实践题答案
# GET: /tasks/:identifier/get_answer_info?answer_id=?
def unlock_answer
@challenge = @game.challenge
@answer = ChallengeAnswer.find(params[:answer_id])
challenge = @answer.challenge
# 解锁需要本层级的答案是否需要扣分
points = challenge.challenge_answers.where(level: @game.answer_open+1..@answer.level).sum(:score)
points = challenge.challenge_answers.where(level: @game.answer_open + 1..@answer.level).sum(:score)
deduct_score = ((points / 100.0) * challenge.score).to_i
uid_logger("############金币数目: #{current_user.grade}")
unless current_user.grade.to_i - deduct_score > 0
@ -263,15 +274,16 @@ class GamesController < ApplicationController
begin
# 积分消耗情况记录
score = challenge.st.zero? ? -deduct_score : -challenge.choose_score.to_i
RewardGradeService.call(current_user, container_id: @answer.id, container_type: 'Answer', score: score)
RewardGradeService.call(current_user, container_id: @game.id, container_type: 'Answer', score: score)
# 通关查看答案 不扣 得分
answer_open = @challenge.st == 1 ? 1 : @answer.level
if @game.status == 2
@game.update_attributes!(:answer_open => @answer.level)
@game.update_attributes!(:answer_open =>answer_open)
else
# 扣除总分计算
answer_deduction = challenge.challenge_answers.where("level <= #{@answer.level}").sum(:score)
@game.update_attributes!(:answer_open => @answer.level, :answer_deduction => answer_deduction)
@game.update_attributes!(:answer_open => answer_open, :answer_deduction => answer_deduction)
end
rescue Exception => e
@ -279,7 +291,32 @@ class GamesController < ApplicationController
raise ActiveRecord::Rollback
end
end
end
# 解锁选择题答案
def unlock_choose_answer
@challenge = @game.challenge
score = @challenge.choose_score
unless current_user.grade.to_i - score > 0
tip_exception("您没有足够的金币")
end
ActiveRecord::Base.transaction do
begin
# 积分消耗情况记录
RewardGradeService.call(current_user, container_id: @game.id, container_type: 'Answer', score: -score)
# 通关查看答案 不扣 得分
if @game.status == 2
@game.update_attributes!(:answer_open => 1)
else
# 扣除总分计算
@game.update_attributes!(:answer_open => 1, :answer_deduction => 100)
end
@challenge_answers = @challenge.challenge_chooses
rescue Exception => e
uid_logger_error("#######金币扣除异常: #{e.message}")
raise ActiveRecord::Rollback
end
end
end
# 查看答案需要扣取金币
@ -454,7 +491,7 @@ class GamesController < ApplicationController
begin
@content = git_fle_content(@myshixun.repo_path, path) || ""
rescue
if params[:retry].present?
if params[:retry].to_i == 1
begin
begin
# 检测TPM对应的路径代码是否正常

@ -107,15 +107,9 @@ class HomeworkCommonsController < ApplicationController
student_works = @homework.all_works
@all_member_count = student_works.size
logger.info("###########______@homework.publish_time_________#{@homework.publish_time}")
logger.info("-----------------------------------------------------")
if @homework.publish_time.blank? || (@homework.publish_time > Time.now)
logger.info("+++++++++++++++++#{@homework.publish_time}")
@student_works = []
if (params[:format] == "xlsx") || (params[:format] == "zip")
logger.info("++++++params[:format]params[:format]params[:format]params[:format]+++++++++++#{params[:format]}")
normal_status(-1,"作业未发布")
end
else
@ -213,8 +207,10 @@ class HomeworkCommonsController < ApplicationController
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')
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
# response.set_header("Content-Disposition","attachment; filename=#{exercise_export_name.strip.first(30)}};filename*=utf-8''#{exercise_export_name.strip.first(30)}}")
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}
}
end
@ -1348,7 +1344,7 @@ class HomeworkCommonsController < ApplicationController
end
# 代码查重详情
# 代码查重代码的详情
def code_review_detail
@student_work = @homework.student_works.find_by(user_id: params[:user_id])
@user = @student_work.user

@ -17,7 +17,7 @@ class MyshixunsController < ApplicationController
# 强制重置实训
# 前段需要按照操作过程提示
def reset_my_game
unless current_user.admin?
unless (current_user.admin? || current_user.id == @myshixun.user_id)
tip_exception("403", "")
end

@ -146,7 +146,7 @@ class PollsController < ApplicationController
def edit
ActiveRecord::Base.transaction do
begin
@poll_questions = @poll.poll_questions.order("question_number ASC")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面请求失败!")
@ -183,7 +183,7 @@ class PollsController < ApplicationController
else
@is_teacher_or = 0
end
@poll_questions = @poll.poll_questions&.includes(:poll_answers).order("question_number ASC")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("没有权限")
@ -868,7 +868,6 @@ class PollsController < ApplicationController
@user_poll_status = 0 #可编辑
end
# @answer_user = User.find_by(id:@poll_current_user_id)
@answer_status = []
question_answered = 0
@ -920,12 +919,11 @@ class PollsController < ApplicationController
def commit_result
ActiveRecord::Base.transaction do
begin
@poll_users = @poll.poll_users
@poll_users = @poll.all_poll_users(current_user.id)
@poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1
@limit = params[:limit] || 10
@poll_export_questions = @poll_questions.order("question_number ASC")
@poll_export_questions = @poll_questions
@poll_questions = @poll_questions.page(@page).per(@limit)
if params[:format] == "xlsx"
if @user_course_identity > Course::ASSISTANT_PROFESSOR
@ -936,11 +934,8 @@ class PollsController < ApplicationController
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')}"
render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
poll_questions:@poll_export_questions,
poll:@poll,
poll_users: @poll_users,
poll_commit_ids:@poll_commit_ids}
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}
}
end
end
@ -1153,11 +1148,12 @@ class PollsController < ApplicationController
end
def get_questions_count
@poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC")
@poll_questions_count = @poll_questions.size # 全部的题目数
@poll_question_singles = @poll_questions.ques_count(1).all.size # 单选题
@poll_question_doubles = @poll_questions.ques_count(2).all.size # 多选题
@poll_question_mains = @poll_questions.ques_count(3).all.size #主观题
@poll_questions = @poll.poll_questions.order("question_number ASC")
@poll_questions_count = @poll_questions&.size # 全部的题目数
@poll_question_singles = @poll_questions.ques_count(1).size # 单选题
@poll_question_doubles = @poll_questions.ques_count(2).size # 多选题
@poll_question_mains = @poll_questions.ques_count(3).size #主观题
@poll_questions = @poll_questions&.includes(:poll_answers,:poll_votes).distinct
end
def check_poll_question_complete #commit_poll 的权限
@ -1286,8 +1282,6 @@ class PollsController < ApplicationController
else
normal_status(-1,"请选择分班!")
end
# elsif (@poll.poll_status != 1) && (params[:publish_time].to_time != @poll.publish_time) && (@user_course_identity > Course::CREATOR)
# normal_status(-1,"已发布/已截止的不能修发布时间!") #课堂管理员和超级管理员才有权限
end
end
@ -1301,4 +1295,99 @@ class PollsController < ApplicationController
end
end
#问卷的统计结果的导出
def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids)
sub_commit = []
user_commit = []
poll_users_info = %w(序号)
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| ActionController::Base.helpers.strip_tags(k) if k.present?}
poll_un_anony = poll.un_anonymous
if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号)
else
user_info = []
end
poll_users_info = poll_users_info + user_info + poll_ques_titles
poll_questions.each do |q|
if q.question_type != 3 #问题不为主观题
question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids)&.size #该问题的有效填写量
sheet_row = ["#{q.question_number}"] #选择题答案选项的数组
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
sheet_answer_percent = ["比例"]
sheet_answer_useful = ["本题有效填写人次",question_vote_user]
q.poll_answers.each do |a| #问卷的答案选项
answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids)&.size
answer_percent = (question_vote_user == 0) ? "0.0%" : "#{((answer_users_count / question_vote_user.to_f)*100).round(1).to_s}%"
sheet_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count)
sheet_answer_percent.push(answer_percent)
end
sheet_sub_commit = {
sub_title: sheet_row,
sub_user_votes:[sheet_answer_row,sheet_answer_percent,sheet_answer_useful]
}
sub_commit.push(sheet_sub_commit)
else #主观题答案
user_votes= []
main_show_row = ["#{q.question_number}", q.question_title ]
q.poll_votes.each_with_index do |v,index| #主观题的答案
q_poll_vote = [(index+1), v.vote_text.present? ? v.vote_text : "--"]
user_votes.push(q_poll_vote)
end
sheet_sub_commit = {
sub_title: main_show_row,
sub_user_votes:user_votes
}
sub_commit.push(sheet_sub_commit)
end
end #each_with_index
poll_users.includes(user: [:user_extension,:poll_votes]).each_with_index do |u,index|
u_user = u.user
user_answer_array = []
poll_questions.each do |q|
user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id)
if user_poll_votes.present?
user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?)
user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?)
if user_poll_answer_ids.count > 0
answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids)
if user_poll_answer_ids.count >1
u_answer = answer_content.pluck(:answer_text).join(";")
else
u_answer = answer_content.first.answer_text
end
elsif user_poll_vote_texts.count > 0
if user_poll_vote_texts.count > 1
u_answer = user_poll_vote_texts.join(";")
else
u_answer = user_poll_vote_texts.first
end
else
u_answer = "--"
end
else
u_answer = "--"
end
user_answer_array.push(u_answer)
end
user_cell = [index+1]
if poll_un_anony
user_login = u_user.login
user_name = u_user.real_name.present? ? u_user.real_name : "--"
user_student_id = u_user.student_id.present? ? u_user.student_id : "--"
user_cell += [user_login,user_name, u_user.mail, user_student_id]
end
all_user_cell = user_cell + user_answer_array
user_commit.push(all_user_cell)
end
{
poll_users_info:poll_users_info,
sub_commit:sub_commit,
user_commit:user_commit
}
end
end

@ -522,7 +522,18 @@ class ShixunsController < ApplicationController
end
# 如果存在实训,则直接进入实训
@current_task = current_myshixun.current_task(games)
# 如果实训允许跳关传参params[:challenge_id]跳入具体的关卡
@current_task =
if params[:challenge_id]
game = games.where(challenge_id: params[:challenge_id]).take
if @shixun.task_pass || game.status != 3
game
else
current_myshixun.current_task(games)
end
else
current_myshixun.current_task(games)
end
else
# 如果未创建关卡一定不能开启实训否则TPI没法找到当前的关卡
if @shixun.challenges_count == 0
@ -731,8 +742,8 @@ class ShixunsController < ApplicationController
if apply && apply.status == 0
apply.update_attribute(:status, 3)
apply.tidings.destroy_all
@shixun.update_column('status', 0)
end
@shixun.update_column(:status, 0)
end
private

@ -334,7 +334,6 @@ class StudentWorksController < ApplicationController
ActiveRecord::Base.transaction do
begin
# 没传score则取上次评分成绩
score = StudentWorksScore.where(user_id: current_user.id, student_work_id: @work.id).last
new_score = StudentWorksScore.new
new_score.score = params[:score].blank? ? score.try(:score) : params[:score].to_f
new_score.comment = params[:comment] if params[:comment] && params[:comment].strip != ""
@ -348,7 +347,9 @@ class StudentWorksController < ApplicationController
@work.update_attributes(group_id: @homework.max_group_id) if @homework.homework_type == "group"
end
new_score.reviewer_role = @user_course_identity == Course::STUDENT ? 3 : @user_course_identity == Course::ASSISTANT_PROFESSOR ? 2 : 1
reviewer_role = @user_course_identity == Course::STUDENT ? 3 : @user_course_identity == Course::ASSISTANT_PROFESSOR ? 2 : 1
new_score.reviewer_role = reviewer_role
score = StudentWorksScore.where(user_id: current_user.id, student_work_id: @work.id, reviewer_role: reviewer_role).last
if new_score.save!
Attachment.associate_container(params[:attachment_ids], new_score.id, new_score.class)
@ -381,7 +382,7 @@ class StudentWorksController < ApplicationController
when 3 #学生评分 学生评分显示平均分
# 匿评分
@work.student_score = new_score.stu_score(@work.id)
if @homework.homework_type == "group" && params[:same_score] && new_score.score.present?
if @homework.homework_type == "group" && new_score.score.present?
add_score_to_member @work, @homework, new_score
end
@ -730,19 +731,19 @@ class StudentWorksController < ApplicationController
student_works.each do |st_work|
st_score = StudentWorksScore.new(user_id: new_score.user_id, score: new_score.score,
reviewer_role: new_score.reviewer_role, comment: new_score.comment)
st_work.student_works_scores << st_score
score = StudentWorksScore.where(user_id: new_score.user_id, student_work_id: st_work.id).last
score = StudentWorksScore.where(user_id: new_score.user_id, student_work_id: st_work.id, reviewer_role: new_score.reviewer_role).last
# 该用户的历史评阅无效
score.update_column('is_invalid', true) if score.present? && score.score.present?
st_work.student_works_scores << st_score
if new_score.reviewer_role == 1
st_work.teacher_score = new_score.score
st_work.teacher_score = new_score.score if new_score.score.present?
elsif new_score.reviewer_role == 2
if homework.homework_detail_manual.ta_mode == 1
st_work.teaching_asistant_score = new_score.ta_score st_work.id
else
st_work.teaching_asistant_score = new_score.score
st_work.teaching_asistant_score = new_score.score if new_score.score.present?
end
else
st_work.student_score = student_work.student_score

@ -0,0 +1,39 @@
class Users::AuthAttachmentsController < Users::BaseAccountController
before_action :private_user_resources!
before_action :convert_image!, only: [:update]
def update
image_temp_path = auth_image_path + 'temp' # 上传文件保存至临时文件,提交申请时再移到正常目录
File.delete(image_temp_path) if File.exist?(image_temp_path) # 删除之前的临时文件
Util.write_file(@image, image_temp_path)
render_ok
rescue StandardError => ex
logger_error(ex)
render_error('上传失败')
end
private
def convert_image!
max_size = EduSetting.get('upload_avatar_max_size') || 10 * 1024 * 1024 # 10M
if params[:image].class == ActionDispatch::Http::UploadedFile
@image = params[:image]
render_error('请上传文件') if @image.size.zero?
render_error('文件大小超过限制') if @image.size > max_size
else
image = params[:image].to_s.strip
return render_error('请上传正确的图片') if image.blank?
@image = Util.convert_base64_image(image, max_size: max_size)
end
rescue Base64ImageConverter::Error => ex
render_error(ex.message)
end
def auth_image_path
url_method = params[:type] == 'professional' ? :disk_professional_auth_filename : :disk_real_name_auth_filename
ApplicationController.helpers.send(url_method, observed_user.id)
end
end

@ -0,0 +1,16 @@
class Users::AuthenticationAppliesController < Users::BaseAccountController
before_action :private_user_resources!
def create
Users::ApplyAuthenticationService.call(observed_user, create_params)
render_ok
rescue Users::ApplyAuthenticationService::Error => ex
render_error(ex.message)
end
private
def create_params
params.permit(:name, :id_number, :upload_image)
end
end

@ -0,0 +1,16 @@
class Users::ProfessionalAuthAppliesController < Users::BaseAccountController
before_action :private_user_resources!
def create
Users::ApplyProfessionalAuthService.call(observed_user, create_params)
render_ok
rescue Users::ApplyProfessionalAuthService::Error => ex
render_error(ex.message)
end
private
def create_params
params.permit(:school_id, :department_id, :identity, :extra, :upload_image)
end
end

@ -6,13 +6,11 @@ class ZipsController < ApplicationController
before_action :require_admin_or_teacher
def shixun_report
# student_work_ids = Array.wrap(params[:student_work_ids])
# service = BatchExportShixunReportService.new(@homework, @student_work_ids)
service = BatchExportShixunReportService.new(@homework, @all_student_works)
filename = filename_for_content_disposition(service.filename)
send_file service.zip, filename: filename, type: 'application/zip'
rescue BatchExportShixunReportService::Error => ex
normal_status(-1, ex.message)
@ -23,8 +21,8 @@ class ZipsController < ApplicationController
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
file_name = filename_for_content_disposition(exercises.filename)
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
rescue Exception => e
normal_status(-1, e.message)
end
@ -44,7 +42,7 @@ class ZipsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
@exercise_status = @exercise.get_exercise_status(current_user.id)
@exercise_status = @exercise.present? ? @exercise.get_exercise_status(current_user.id) : 1
group_id = params[:exercise_group_id]
if @exercise.blank?
normal_status(-1,"试卷不存在")
@ -101,11 +99,16 @@ class ZipsController < ApplicationController
def load_homework
@homework = HomeworkCommon.find(params[:homework_common_id])
@homework_status = @homework.present? ? @homework.homework_detail_manual.comment_status : 0
if @homework.blank?
normal_status(-1,"该作业不存在")
elsif @homework_status == 0
normal_status(-1,"该作业未发布")
else
@course = @homework.course
##7。2 -hs新增
@member = @course.course_member(current_user.id)
@all_student_works = @homework.teacher_works(@member).where("work_status > 0")
work_status = params[:work_status]
group_id = params[:course_group]
@ -131,4 +134,5 @@ class ZipsController < ApplicationController
normal_status(-2,"100")
end
end
end
end

@ -0,0 +1,8 @@
class Users::ApplyAuthenticationForm
include ActiveModel::Model
attr_accessor :name, :id_number, :upload_image
validates :name, presence: true
validates :id_number, presence: true
end

@ -0,0 +1,10 @@
class Users::ApplyProfessionalAuthForm
include ActiveModel::Model
attr_accessor :school_id, :department_id, :identity, :extra, :upload_image
validates :school_id, presence: true, numericality: { only_integer: true, greater_than: 0 }
validates :department_id, numericality: { only_integer: true, greater_than: 0 }, allow_blank: true
validates :identity, presence: true, inclusion: { in: %w(student teacher professional) }
validates :extra, presence: true
end

@ -145,6 +145,18 @@ module ApplicationHelper
File.join(storage_path, "#{source_type}", "#{source_id}")
end
def disk_auth_filename(source_type, source_id, type)
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
end
def disk_real_name_auth_filename(source_id)
disk_auth_filename('UserAuthentication', source_id, 'ID')
end
def disk_professional_auth_filename(source_id)
disk_auth_filename('UserAuthentication', source_id, 'PRO')
end
def shixun_url_to_avatar(shixun)
if File.exist?(disk_filename(shixun.class, shixun.id))
File.join("images/#{relative_path}", "#{shixun.class}", "#{shixun.id}")

@ -251,15 +251,14 @@ module ExercisesHelper
#获取试卷的已答/未答人数
def get_exercise_answers(ex_users)
@commit_ex_users = ex_users.commit_exercise_by_status(1) #当前老师的全部学生中已提交的
@exercise_answers = @commit_ex_users.present? ? @commit_ex_users.size : 0 #表示已经提交了的用户
course_all_members_count = ex_users.present? ? ex_users.size : 0
@exercise_answers = ex_users.commit_exercise_by_status(1).size #表示已经提交了的用户
course_all_members_count = ex_users.exists? ? ex_users.size : 0
@exercise_unanswers = (course_all_members_count - @exercise_answers)
end
def exercise_index_show(exercise,course,is_teacher_or,user)
# exercise_all_users = exercise.exercise_users
# lock_icon 0出现锁1不出现锁
ex_show_text = []
if course.is_end #课堂停止后,试卷显示为已结束
@ -280,6 +279,7 @@ module ExercisesHelper
else
ex_show_text
end
if is_teacher_or == 1
exercise_users_list = exercise.all_exercise_users(user.id) #当前老师所在班级的全部学生
unreview_count = exercise_users_list.exercise_unreview.size
@ -288,7 +288,7 @@ module ExercisesHelper
exercise_publish_time = ex_pb_time[:publish_time]
exercise_end_time = ex_pb_time[:end_time]
current_status = 3
lock_icon = 1 #不显示锁图标
lock_icon = 0
if exercise_status == 1
ex_show_text.push("未发布")
elsif exercise_status == 3
@ -302,7 +302,7 @@ module ExercisesHelper
exercise_publish_time = ex_pb_time[:publish_time]
exercise_end_time = ex_pb_time[:end_time]
current_status = exercise.check_user_answer_status(user)
lock_icon = 1 #不显示锁图标
lock_icon = 0
if current_status == 4
ex_show_text.push("未提交")
end
@ -314,16 +314,20 @@ module ExercisesHelper
unreview_count = nil
if exercise.is_public
current_status = exercise.check_user_answer_status(user)
lock_icon = 1 #非课堂成员,但是试卷为公开的,不加
lock_icon = 1 #不出现
if current_status == 4
ex_show_text.push("未提交")
end
else
current_status = 4
lock_icon = 0 #显示锁图标
lock_icon = 0
end
end
if (course.is_public == 1) && exercise.is_public
lock_icon = 1
end
if exercise_status > 1
show_unreview_count = unreview_count
else
@ -332,8 +336,6 @@ module ExercisesHelper
if exercise_status == 2 && exercise_end_time.present?
ex_left_time = how_much_time(exercise_end_time)
# elsif exercise_status == 3 && course.end_date.present?
# ex_left_time = how_much_time(course.end_date.to_time)
else #已截止后不显示时间
ex_left_time = nil
end
@ -721,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.present? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0
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_user_start为0
if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill

@ -40,10 +40,17 @@ module ExportHelper
works.includes(user: :user_extension, student_works_scores: :user).each_with_index do |w, index|
w_user = w.user
w_1 = (index + 1)
w_2 = w_user.login
w_3 = w_user.real_name
w_3_1 = w_user.mail
if w_user.present?
w_2 = w_user&.login
w_3 = w_user&.real_name
w_3_1 = w_user&.mail
w_4 = w_user.student_id.present? ? w_user.student_id : "--"
else
w_2 = "--"
w_3 = "--"
w_3_1 = "--"
w_4 = "--"
end
course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--"
#0 未提交, 1 按时提交, 2 延迟提交
@ -487,6 +494,8 @@ module ExportHelper
zipfile_name = "#{output_path}/#{rename_zipfile}"
# 同名文件重命名时用
index = 1
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
files_paths.each do |filename|
@ -496,7 +505,11 @@ module ExportHelper
begin
zipfile.add(rename_file, filename)
rescue Exception => e
zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write "该作品中有重复命名文件,请通过文件名学号和姓名信息进入该作业详细界面手动下载"}
rename_file = rename_same_file(rename_file, index)
index += 1
zipfile.add(rename_file, filename)
# zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write "该作品中有重复命名文件,请通过文件名学号和姓名信息进入该作业详细界面手动下载"}
next
end
end
@ -516,4 +529,11 @@ module ExportHelper
def format_sheet_name name
name = name.gsub(":", "-")
end
def rename_same_file(name, index)
basename = File.basename(name, ".*")
new_basename = basename + "_" + index.to_s
extname = File.extname(name)
new_basename + extname
end
end

@ -127,4 +127,5 @@ module PollsHelper
"login":user.login
}
end
end

@ -0,0 +1,67 @@
# 学生加入课堂时创建相关任务作品
class CourseAddStudentCreateWorksJob < ApplicationJob
queue_as :course_member
def perform(course_id, student_ids)
course = Course.find_by(id: course_id)
return if course.blank?
# 如果之前存在相关作品则更新is_delete字段
student_works = StudentWork.joins(:homework_common).where(user_id: student_ids, homework_commons: {course_id: course.id})
student_works.update_all(is_delete: 0)
exercise_users = ExerciseUser.joins(:exercise).where(user_id: student_ids, exercises: {course_id: course.id})
exercise_users.update_all(is_delete: 0)
poll_users = PollUser.joins(:poll).where(user_id: student_ids, polls: {course_id: course.id})
poll_users.update_all(is_delete: 0)
graduation_works = course.graduation_works.where(user_id: student_ids)
graduation_works.update_all(is_delete: 0)
attrs = %i[homework_common_id user_id created_at updated_at]
StudentWork.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
same_attrs = {user_id: user_id}
course.homework_commons.where(homework_type: %i[normal group practice]).each do |homework|
next if homework.student_works.where(user_id: user_id).any?
worker.add same_attrs.merge(homework_common_id: homework.id)
end
end
end
attrs = %i[exercise_id user_id created_at updated_at]
ExerciseUser.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
same_attrs = {user_id: user_id}
course.exercises.each do |exercise|
next if exercise.exercise_users.where(user_id: user_id).any?
worker.add same_attrs.merge(exercise_id: exercise.id)
end
end
end
attrs = %i[poll_id user_id created_at updated_at]
PollUser.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
same_attrs = {user_id: user_id}
course.polls.each do |poll|
next if poll.poll_users.where(user_id: user_id).any?
worker.add same_attrs.merge(poll_id: poll.id)
end
end
end
attrs = %i[graduation_task_id user_id course_id created_at updated_at]
GraduationWork.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
same_attrs = {user_id: user_id, course_id: course.id}
course.graduation_tasks.each do |task|
next if task.graduation_works.where(user_id: user_id).any?
worker.add same_attrs.merge(graduation_task_id: task.id)
end
end
end
end
end

@ -0,0 +1,19 @@
class CourseDeleteStudentDeleteWorksJob < ApplicationJob
queue_as :course_member
def perform(course_id, student_ids)
course = Course.find_by(id: course_id)
return if course.blank?
student_works = StudentWork.joins(:homework_common).where(user_id: student_ids, homework_commons: {course_id: course.id})
student_works.update_all(is_delete: 1)
exercise_users = ExerciseUser.joins(:exercise).where(user_id: student_ids, exercises: {course_id: course.id})
exercise_users.update_all(is_delete: 1)
poll_users = PollUser.joins(:poll).where(user_id: student_ids, polls: {course_id: course.id})
poll_users.update_all(is_delete: 1)
course.graduation_works.where(user_id: student_ids).update_all(is_delete: 1)
end
end

@ -31,7 +31,7 @@ class ExercisePublishNotifyJob < ApplicationJob
Tiding.bulk_insert(*attrs) do |worker|
teacher_ids = teachers.pluck(:user_id)
unless exercise.tidings.exists?(parent_container_type: 'ExercisePublish', user_id: teacher_ids)
teacher_ids.find_each do |user_id|
teacher_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end

@ -20,7 +20,7 @@ class GraduationTaskPublishNotifyJob < ApplicationJob
viewed: 0, tiding_type: 'GraduationTask'
}
Tiding.bulk_insert(*attrs) do |worker|
course.course_members.pluck(:user_id).uniq.find_each do |user_id|
course.course_members.pluck(:user_id).uniq.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end

@ -11,7 +11,7 @@ class HomeworkAbsencePenaltyCalculationJob < ApplicationJob
homework_common.student_works.where("work_status != 0").each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where(student_work_id: work_ids).count -
student_work.user.student_works_scores.where(student_work_id: work_ids, reviewer_role: 3).group_by(:student_work_id).count
student_work.user.student_works_scores.where(student_work_id: work_ids, reviewer_role: 3).group_by(&:student_work_id).count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save

@ -2,7 +2,7 @@ class HomeworkEndUpdateScoreJob < ApplicationJob
# 不允许补交的作业截止后,或者补交截止后需要重新计算一次作业成绩
queue_as :score
def perform(*args)
def perform(homework_id)
homework = HomeworkCommon.find_by(id: homework_id)
return if homework.blank?
course = homework.course
@ -16,7 +16,8 @@ class HomeworkEndUpdateScoreJob < ApplicationJob
student_works = homework.student_works.where(user_id: user_ids)
end
myshixuns = Myshixun.where(shixun_id: params[:shixun_id], user_id: user_ids).
shixun_id = homework.homework_commons_shixun.try(:shixun_id)
myshixuns = Myshixun.where(shixun_id: shixun_id, user_id: user_ids).
includes(:games).where(games: {challenge_id: homework.homework_challenge_settings.pluck(:challenge_id)})
challenge_settings = homework.homework_challenge_settings
myshixuns.find_each(batch_size: 100) do |myshixun|

@ -31,7 +31,7 @@ class PollPublishNotifyJob < ApplicationJob
Tiding.bulk_insert(*attrs) do |worker|
teacher_ids = teachers.pluck(:user_id)
unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids)
teacher_ids.find_each do |user_id|
teacher_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end

@ -10,7 +10,7 @@ class Challenge < ApplicationRecord
has_many :games, :dependent => :destroy
has_many :challenge_chooses, :dependent => :destroy
has_many :homework_challenge_settings, :dependent => :destroy
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
has_one :praise_tread_cache, as: :object, dependent: :destroy
has_many :tidings
# 参考答案
@ -20,7 +20,7 @@ class Challenge < ApplicationRecord
# acts_as_attachable
scope :base_attrs, -> { select([:id, :subject, :position, :shixun_id, :st, :score, :path, :task_pass, :modify_time,
:web_route, :answer, :exec_time]) }
:web_route, :answer, :exec_time, :praises_count]) }
scope :choose_type, -> { where(st: 1) }
scope :practice_type, -> { where(st: 0) }
@ -76,16 +76,20 @@ class Challenge < ApplicationRecord
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
def user_tpi_status user_id
# todo: 以前没加索引导致相同关卡,同一用户有多个games
game = games.last
# 允许跳关则直接开启
game = games.where(user_id: user_id).take
if game.blank?
self.position == 1 ? 1 : 0
position == 1 ? 1 : 0
else
if game.status == 3
shixun.task_pass ? 1 : 0
elsif game.status == 2
2
else
1
end
end
end
## 选择题答案
def choose_answer

@ -20,8 +20,8 @@ class CourseMember < ApplicationRecord
# 未分班
scope :ungroup_students, -> { where(course_group_id: 0, role: 4) }
after_destroy :delete_works
after_create :work_operation
# after_destroy :delete_works
# after_create :work_operation
def delete_works
if self.role == "STUDENT"
course = self.course
@ -52,13 +52,13 @@ class CourseMember < ApplicationRecord
def recover_works
course = self.course
student_works = StudentWork.where(user_id: self.user_id, homework_common_id: course.homework_commons)
student_works = StudentWork.joins(:homework_common).where(user_id: self.user_id, homework_commons: {course_id: course.id})
student_works.update_all(is_delete: 0)
exercise_users = ExerciseUser.where(user_id: self.user_id, exercise_id: course.exercises)
exercise_users = ExerciseUser.joins(:exercise).where(user_id: self.user_id, exercises: {course_id: course.id})
exercise_users.update_all(is_delete: 0)
poll_users = PollUser.where(user_id: self.user_id, poll_id: course.polls)
poll_users = PollUser.joins(:poll).where(user_id: self.user_id, polls: {course_id: course.id})
poll_users.update_all(is_delete: 0)
graduation_works = course.graduation_works.where(user_id: self.user_id)

@ -5,7 +5,7 @@ class Discuss < ApplicationRecord
belongs_to :parent, class_name: 'Discuss', foreign_key: :parent_id, optional: true
has_many :children, -> { reorder(created_at: :asc) }, class_name: 'Discuss', foreign_key: :parent_id
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
has_many :tidings, as: :container, dependent: :destroy
has_one :praise_tread_cache, as: :object, dependent: :destroy

@ -69,11 +69,7 @@ class Exercise < ApplicationRecord
def common_published_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id)
if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布分班
un_group_ids = [0]
else
un_group_ids = []
end
un_group_ids = (course.none_group_count > 0) ? [0] : []
published_group_ids = (current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id及未分班
else
ex_group_setting = exercise_group_settings.pluck("course_group_id").uniq
@ -89,11 +85,7 @@ class Exercise < ApplicationRecord
ex_group_settings = exercise_group_settings.pluck(:course_group_id)
member = course.course_members.course_find_by_ids("user_id",user_id)
member_group_id = member.pluck(:course_group_id).uniq
if (member_group_id & ex_group_settings).size > 0 || user_identity < Course::STUDENT
true
else
false
end
((member_group_id & ex_group_settings).size > 0 || user_identity < Course::STUDENT) ? true : false
end
#判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间
@ -130,11 +122,11 @@ class Exercise < ApplicationRecord
else
ex_group_setting = exercise_group_settings
user_group = course.students.course_find_by_ids("user_id",user_id)
if user_group.present?
if user_group.exists?
user_group_id = user_group.first.course_group_id
user_ex_group_setting = ex_group_setting.find_in_exercise_group("course_group_id",user_group_id)
pb_time = user_ex_group_setting.present? ? user_ex_group_setting.first.publish_time : nil
en_time = user_ex_group_setting.present? ? user_ex_group_setting.first.end_time : nil
pb_time = user_ex_group_setting.exists? ? user_ex_group_setting.first.publish_time : nil
en_time = user_ex_group_setting.exists? ? user_ex_group_setting.first.end_time : nil
else
pb_time = nil
en_time = nil
@ -152,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.present? && (ex_answer_user.start_at.present? || ex_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
if ex_answer_user.exists? && (ex_answer_user.start_at.exists? || ex_answer_user.end_at.exists?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = ex_answer_user.commit_status
end
if ex_answer_user.present? && ex_answer_user.start_at.blank? && user_ex_status == 3
if ex_answer_user.exists? && ex_answer_user.start_at.blank? && user_ex_status == 3
user_status = 4
end

@ -56,7 +56,7 @@ class Myshixun < ApplicationRecord
# status:0 可以测评的; 1 正在测评的; 2评测通过的 3未开启的
# 如果都完成,则当前任务为最后一个任务
def current_task games
current_game = games.select{|game| game.status == 1 || game.status == 0}.first
current_game = games.select{|game| game.status == 1 || game.status == 0}.last
if current_game.blank?
current_game = games.last
end

@ -4,7 +4,7 @@ class UserExtension < ApplicationRecord
belongs_to :user
belongs_to :school
belongs_to :department
belongs_to :department, optional: true
def identity_text
I18n.t("user.identity.#{identity}")

@ -3,7 +3,6 @@ class BatchExportShixunReportService
MAX_BATCH_LIMIT = 20
# attr_reader :homework, :student_work_ids
attr_reader :homework, :all_student_works
@ -15,7 +14,7 @@ class BatchExportShixunReportService
end
def filename
@_filename ||= "#{Time.now.strftime('%Y%m%d%H%M%S')}-#{homework.name}.zip"
@_filename ||= "#{homework.name}-#{Time.now.strftime('%Y%m%d%H%M%S')}.zip"
end
def zip
@ -37,7 +36,7 @@ class BatchExportShixunReportService
rescue => ex
Rails.logger.error(ex.message)
zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write('文件重复') }
zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") }
next
end
end
@ -45,15 +44,4 @@ class BatchExportShixunReportService
end
end
# private
#
# def validate!
# if student_work_ids.size.zero?
# raise Error, '请选择学生实训作业'
# end
#
# if student_work_ids.size > MAX_BATCH_LIMIT
# raise Error, '导出实训报告太多,请分批导出'
# end
# end
end

@ -10,7 +10,7 @@ class ExportShixunReportService
end
def filename
@_filename ||= "#{homework.name}-#{work.user.user_extension&.student_id}-#{work.user.real_name}.pdf".gsub(' ', '-').gsub('/', '_')
@_filename ||= "#{homework.name}-#{work.user&.student_id}-#{work.user.real_name}.pdf".gsub(' ', '-').gsub('/', '_')
end
def prepare_binding

@ -47,7 +47,7 @@ class ShixunsService
if current_user.admin?
disscuss_count = Discuss.where(dis_id: dis_id, dis_type: dis_type, root_id: nil).count
discusses = Discuss.where(dis_id: dis_id, dis_type: dis_type, root_id: nil)
.includes(:user, :praise_tread).limit(LIMIT).offset(offset)
.includes(:user, :praise_treads).limit(LIMIT).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)',
@ -55,7 +55,7 @@ class ShixunsService
)
disscuss_count = disscusses.count
discusses = disscusses.includes(:user, :praise_tread).limit(LIMIT).offset(offset)
discusses = disscusses.includes(:user, :praise_treads).limit(LIMIT).offset(offset)
end
base_data discusses, dis, current_user
@ -81,7 +81,7 @@ class ShixunsService
offset = page * LIMIT
find_status = true if position
end
discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).includes(:user, :praise_tread).offset(offset)
discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).includes(:user, :praise_treads).offset(offset)
base_data discusses, dis, current_user
Myshixun.find(params[:myshixun_id]).update_attribute(:onclick_time, Time.now)
@ -109,8 +109,8 @@ class ShixunsService
if discusses.present?
discusses.each do |d|
# 总点赞数
praise_count = d.praise_tread.where(:praise_or_tread => 1).count
user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
praise_count = d.praises_count
user_praise= d.praise_treads.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
manager = current_user.manager_of_shixun?(dis, current_user)
game_url =
if manager

@ -0,0 +1,52 @@
class Users::ApplyAuthenticationService < ApplicationService
Error = Class.new(StandardError)
attr_reader :user, :params
def initialize(user, params)
@user = user
@params = params
end
def call
Users::ApplyAuthenticationForm.new(params).validate!
raise Error, '您已经申请过实名认证了' if ApplyUserAuthentication.real_name_auth.processing.exists?(user_id: user.id)
user.lastname = params[:name].to_s.strip
user.firstname = ''
user.ID_number = params[:id_number].to_s.strip.presence
ActiveRecord::Base.transaction do
user.authentication = false
user.save!
user.apply_user_authentication.create!(auth_type: 1, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false'
sms_notify_admin
end
user
end
private
def move_image_file!
image_url = ApplicationController.helpers.disk_real_name_auth_filename(user.id)
temp_image_url = image_url + 'temp'
FileUtils.mv(temp_image_url, image_url, force: true) if File.exist?(temp_image_url)
rescue RuntimeError => ex
Util.logger_error(ex)
raise Error, '申请失败'
ensure
File.delete(temp_image_url) if File.exist?(temp_image_url)
end
def sms_notify_admin
Educoder::Sms.notify_admin(send_type: 'apply_auth')
rescue => ex
Util.logger_error(ex)
end
end

@ -0,0 +1,62 @@
class Users::ApplyProfessionalAuthService < ApplicationService
Error = Class.new(StandardError)
attr_reader :user, :params
def initialize(user, params)
@user = user
@params = params
end
def call
Users::ApplyProfessionalAuthForm.new(params).validate!
raise Error, '您已经申请过职业认证了' if ApplyUserAuthentication.professional_auth.processing.exists?(user_id: user.id)
user.professional_certification = false
extension = user.user_extension
extension.school_id = params[:school_id]
extension.department_id = params[:department_id]
extension.identity = params[:identity]
extra = params[:extra].to_s.strip.presence
if extension.identity.to_s == 'student'
extension.technical_title = nil
extension.student_id = extra
else
extension.technical_title = extra
extension.student_id = nil
end
ActiveRecord::Base.transaction do
user.save!
extension.save!
user.apply_user_authentication.create!(auth_type: 2, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false'
sms_notify_admin
end
end
private
def move_image_file!
image_url = ApplicationController.helpers.disk_professional_auth_filename(user.id)
temp_image_url = image_url + 'temp'
FileUtils.mv(temp_image_url, image_url, force: true) if File.exist?(temp_image_url)
rescue RuntimeError => ex
Util.logger_error(ex)
raise Error, '申请失败'
ensure
File.delete(temp_image_url) if File.exist?(temp_image_url)
end
def sms_notify_admin
Educoder::Sms.notify_admin(send_type: 'apply_pro_certification')
rescue => ex
Util.logger_error(ex)
end
end

@ -17,7 +17,7 @@ if @challenges.present?
json.passed_count challenge.user_passed_count
json.playing_count challenge.playing_count
json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.open_game challenge.open_game(@user.id, @shixun)
#json.open_game challenge.open_game(@user.id, @shixun)
if @editable
json.edit_url edit_shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.delete_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)

@ -14,8 +14,8 @@ json.game_url discuss.game_url(container, current_user)
if discuss.parent_id
json.can_delete discuss.can_deleted?(current_user)
else
json.praise_count discuss.praise_tread.where(praise_or_tread: 1).count
json.user_praise discuss.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
json.praise_count discuss.praises_count
json.user_praise discuss.praise_treads.select{|pt| pt.user_id == current_user.id}.length > 0
end

@ -1,22 +1,4 @@
json.exercises_counts do
json.exercises_total_counts @exercises_count #全部试卷数
json.exercises_all_counts @exercises_select_count #选择后的全部试卷数
json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数
json.exercises_published_counts @exercises_published_counts #已发布试卷数
json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
json.left_banner_id @left_banner_id
json.left_banner_name @left_banner_name
end
json.course_types do
json.course_status @course.is_end ? 1 : 0 #课堂的当前是否结束如结束则为1否则为0
json.course_end_time @course.end_date #课堂的截止时间
json.course_is_public @course.is_public #判断课堂是否为公开,只有公开课才有设为公开的按钮
json.user_permission @is_teacher_or # 当前用户存在且为课堂教师/管理员/超级管理员时为1 课堂成员为2否则为0
end
if @exercises_count > 0
json.exercises do
json.array! @exercises do |exercise|
@ -43,3 +25,22 @@ else
json.exercises []
end
json.course_types do
json.course_status @course.is_end ? 1 : 0 #课堂的当前是否结束如结束则为1否则为0
json.course_end_time @course.end_date #课堂的截止时间
json.course_is_public @course.is_public #判断课堂是否为公开,只有公开课才有设为公开的按钮
json.user_permission @is_teacher_or # 当前用户存在且为课堂教师/管理员/超级管理员时为1 课堂成员为2否则为0
end
json.exercises_counts do
json.exercises_total_counts @exercises_count #全部试卷数
json.exercises_all_counts @exercises_select_count #选择后的全部试卷数
json.exercises_unpublish_counts @exercises_unpublish_counts #未发布试卷数
json.exercises_published_counts @exercises_published_counts #已发布试卷数
json.exercises_ended_counts @exercises_ended_counts #已截止试卷数
json.left_banner_id @left_banner_id
json.left_banner_name @left_banner_name
end

@ -3,8 +3,8 @@ json.data do
json.id @category_id
json.name @category_name
json.total_count @total_count
json.public_count @public_count
json.private_count @private_count
json.publish_count @publish_count
json.unpublish_count @unpublish_count
json.course_is_public @course.is_public?
json.files do
json.array! @attachments do |attachment|

@ -1,5 +1,6 @@
index = 0
json.status 3
# st: 0 实践题 1 选择题
json.message do
json.array! @challenge_answers do |answer|
index += 1
@ -13,3 +14,5 @@ json.message do
end
end

@ -0,0 +1,6 @@
json.choose_answers do
json.array! @challenge_chooses do |choose|
json.position choose.position
json.answer choose.answer.blank? ? choose.standard_answer : choose.answer
end
end

@ -0,0 +1,6 @@
json.choose_answers do
json.array! @challenge_chooses do |choose|
json.position choose.position
json.answer choose.answer.blank? ? choose.standard_answer : choose.answer
end
end

@ -1,5 +1,5 @@
wb = xlsx_package.workbook
wb.use_autowidth = false
# wb.use_autowidth = false
wb.use_shared_strings = true
wb.styles do |s|
@ -9,13 +9,13 @@ wb.styles do |s|
bg_cc = s.add_style :bg_color=> "CCC1DA",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_ff = s.add_style :bg_color=> "FFC000",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_bb = s.add_style :bg_color=> "9BBB59",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
wb.add_worksheet(:name => "毕设选题情况汇总") do |sheet|
sheet.sheet_view.show_grid_lines = false
sheet_title = table_columns
sheet_title_c = sheet_title.count
sheet.add_row sheet_title, :style => bg_cell
sheet.add_row sheet_title,:height => 32, :style => bg_cell
sheet["J1:L1"].each { |c| c.style = bg_db }
sheet["M1:O1"].each { |c| c.style = bg_cc }
sheet["P1:Q1"].each { |c| c.style = bg_d2 }
@ -23,10 +23,10 @@ wb.styles do |s|
sheet["U1:W1"].each { |c| c.style = bg_bb }
if topic_users.count > 0
topic_users.each do |user|
sheet.add_row user, :style => sz_all
sheet.add_row user,:height => 18, :style => sz_all
end #each_widh_index
else
sheet.add_row ["--"]*sheet_title_c
sheet.add_row ["--"]*sheet_title_c,:height => 18
end
sheet.column_widths *([15]*sheet.column_info.count)

@ -1,6 +1,8 @@
if identity == Course::STUDENT
if homework.homework_type == "practice"
json.task_operation task_operation_url(work.try(:myshixun), homework.shixuns.take)
shixun = homework.shixuns.take
myshixun = work.try(:myshixun) ? work.myshixun : shixun.myshixuns.find_by(user_id: work.user_id)
json.task_operation task_operation_url(myshixun, shixun)
json.view_report work.work_status > 0
json.commit_des commit_des_status(work, homework)
else

@ -7,11 +7,14 @@ json.group_list do
end
end
# 未分班展示情况放在最后
if @course_groups.count > 0 && @course_groups.count < @limit.to_i
if @course_groups.count < @limit.to_i
ungroup_work_count = homework_ungroup_works_count(@homework, @ungroup_user_ids)
if ungroup_work_count > 0
json.ungroup_list do
json.id 0
json.name "未分班"
json.work_count homework_ungroup_works_count @homework, @ungroup_user_ids
json.work_count ungroup_work_count
json.last_review_time ungroup_last_review_time @homework
end
end
end

@ -13,6 +13,7 @@ json.ta_mode @homework_detail_manual.ta_mode
json.is_evaluation @is_evaluation ? @is_evaluation : false
json.work_public @homework.work_public
json.allow_late @homework.allow_late
if @user_course_identity < Course::STUDENT

@ -7,88 +7,33 @@ wb.styles do |s|
wb.add_worksheet(:name => "统计结果") do |sheet|
sheet.sheet_view.show_grid_lines = false
poll_users_info = %w(序号)
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?}
poll_un_anony = poll.un_anonymous
if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号)
else
user_info = []
sub_commit = polls_user_commit[:sub_commit]
poll_user_info = polls_user_commit[:poll_users_info]
user_commit = polls_user_commit[:user_commit]
if sub_commit&.size > 0
sub_commit.each do |sub|
main_sub_title = sub[:sub_title]
main_sub_content = sub[:sub_user_votes]
sheet.add_row main_sub_title,:height =>15, :style => blue_cell
if main_sub_content.present?
main_sub_content.each do |con|
sheet.add_row con,:height =>15, :style => sz_all
end
poll_users_info = poll_users_info + user_info + poll_ques_titles
poll_questions.each do |q|
if q.question_type != 3 #问题不为主观题
question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).count #该问题的有效填写量
sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
sheet_answer_percent = ["比例"]
sheet_answer_useful = ["有效填写人次",question_vote_user]
q.poll_answers.each do |a| #问卷的答案选项
answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).count
answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1)
sheet_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count)
sheet_answer_percent.push(answer_percent.to_s)
end
sheet.add_row sheet_row, :height =>15,:style => blue_cell
sheet.add_row sheet_answer_row, :height =>15, :style => sz_all
sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all
sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all
#合并单元格但无法填充style
# sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index))
# sheet.rows[sheet.rows.last.row_index].style = sz_all
sheet.add_row []
else #主观题答案
main_show_row = ["第#{q.question_number}题",q.question_title]
sheet.add_row main_show_row,:height =>15, :style => blue_cell
q.poll_votes.each do |v| #主观题的答案
sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all
end
sheet.add_row [], :style => sz_all
end
end #each_with_index
sheet.add_row poll_users_info, :height =>15, :style => blue_cell
poll_users.each_with_index do |u,index|
u_user = u.user
user_answer_array = []
poll_questions.each do |q|
user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id)
if user_poll_votes.present?
user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?)
user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?)
if user_poll_answer_ids.count > 0
answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids)
if user_poll_answer_ids.count >1
u_answer = answer_content.pluck(:answer_text).join(";")
else
u_answer = answer_content.first.answer_text
end
elsif user_poll_vote_texts.count > 0
if user_poll_vote_texts.count > 1
u_answer = user_poll_vote_texts.join(";")
else
u_answer = user_poll_vote_texts.first
end
else
u_answer = "--"
end
else
u_answer = "--"
end
user_answer_array.push(u_answer)
end
user_cell = [index+1]
if poll_un_anony
user_login = u_user.login
user_name = u_user.real_name.present? ? u_user.real_name : "--"
user_student_id = u_user.student_id.present? ? u_user.student_id : "--"
user_cell += [user_login,user_name, u_user.mail, user_student_id]
sheet.add_row poll_user_info, :height =>15, :style => blue_cell
if user_commit&.size > 0
user_commit.each do |com|
sheet.add_row com, :height =>15,:style => sz_all
end
all_user_cell = user_cell + user_answer_array
sheet.add_row all_user_cell, :height =>15,:style => sz_all
end
sheet.column_widths *([25]*sheet.column_info.count)
sheet.column_info.first.width = 10
sheet.column_info.first.width = 15
end #add_worksheet
end

@ -0,0 +1,7 @@
'zh-CN':
activemodel:
attributes:
users/apply_authentication_form:
name: 姓名
id_number: 身份证号

@ -0,0 +1,9 @@
'zh-CN':
activemodel:
attributes:
users/apply_professional_auth_form:
school_id: 学校/单位
department_id: 学院/部门
identity: 职业
extra: 职称/学号

@ -74,6 +74,9 @@ Rails.application.routes.draw do
resource :email_bind, only: [:create]
resource :password, only: [:update]
resource :avatar, only: [:update]
resource :auth_attachment, only: [:update]
resource :authentication_apply, only: [:create]
resource :professional_auth_apply, only: [:create]
end
end
end
@ -121,6 +124,8 @@ Rails.application.routes.draw do
get :get_answer_info
get :unlock_answer
get :check_test_sets
get :unlock_choose_answer
get :get_choose_answer
end
collection do

@ -5,4 +5,5 @@
- [default, 3]
- [score, 4]
- [evaluation_comment, 5]
- [course_member, 6]
- [notify, 100]

@ -0,0 +1,5 @@
class AddPraisesCountForChallenges < ActiveRecord::Migration[5.2]
def change
add_column :challenges, :praises_count, :integer, :default => 0
end
end

@ -0,0 +1,9 @@
class ModifyPraisesCountForChallenges < ActiveRecord::Migration[5.2]
def change
challenges = Challenge.where(nil).unscoped
challenges.find_each do |c|
praises_count = c.praise_treads.where(praise_or_tread: 1).count
c.update_column(:praises_count, praises_count)
end
end
end

@ -0,0 +1,5 @@
class AddPraisesCountForDiscuess < ActiveRecord::Migration[5.2]
def change
add_column :discusses, :praises_count, :integer, :default => 0
end
end

@ -0,0 +1,9 @@
class ModifyPraisesCountForDiscuess < ActiveRecord::Migration[5.2]
def change
discusses = Discuss.includes(:praise_treads).unscoped
discusses.find_each do |d|
praises_count = d.praise_treads.liker.count
d.update_column(:praises_count, praises_count)
end
end
end

@ -21,7 +21,7 @@ module Educoder
def self.notify_admin(opt)
opt[:name] = '管理员'
opt[:mobile] = ENV['NOTIDY_ADMIN_PHONE'] || '17680641960'
opt[:mobile] = ENV['NOTIFY_ADMIN_PHONE'] || EduSetting.get('notify_admin_phone') || '17680641960'
send(opt)
end

@ -60,16 +60,19 @@ namespace :homework_evaluation do
HomeworkAnonymousAppealStartNotifyJob.perform_later(homework_common.id)
else
homework_detail_manual.update_column('comment_status', 5)
end
# 没有申诉阶段则直接计算缺评扣分 否则申诉结束时才计算
HomeworkAbsencePenaltyCalculationJob.perform_later(homework_common.id)
end
end
end
end
#自动关闭申诉的任务
task :end_appeal => :environment do
homework_detail_manuals = HomeworkDetailManual.where("appeal_time <= '#{Time.now}' and homework_detail_manuals.comment_status = 4")
homework_detail_manuals.update_all(:comment_status => 5)
homework_detail_manuals.each do |homework_detail_manual|
HomeworkAbsencePenaltyCalculationJob.perform_later(homework_detail_manual.homework_common_id)
end
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CourseAddStudentCreateWorksJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CourseDeleteStudentDeleteWorksJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save