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

dev_forum
jasder 5 years ago
commit b3db447044

@ -83,7 +83,6 @@ class AccountsController < ApplicationController
email = params[:login] email = params[:login]
verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last
user = User.find_by_mail(email) #这里有问题应该是为email,而不是mail 6.13-hs user = User.find_by_mail(email) #这里有问题应该是为email,而不是mail 6.13-hs
end end
check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
unless check_code unless check_code

@ -23,6 +23,13 @@ class ApplicationController < ActionController::Base
EduSetting.get(name) EduSetting.get(name)
end end
# 实训的访问权限
def shixun_access_allowed
if !current_user.shixun_permission(@shixun)
tip_exception(403, "..")
end
end
def user_course_identity def user_course_identity
@user_course_identity = current_user.course_identity(@course) @user_course_identity = current_user.course_identity(@course)
if @user_course_identity > Course::STUDENT && @course.is_public == 0 if @user_course_identity > Course::STUDENT && @course.is_public == 0

@ -5,8 +5,10 @@ class ChallengesController < ApplicationController
before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up, before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up,
:edit_choose_question, :show_choose_question, :destroy_challenge_choose, :edit_choose_question, :show_choose_question, :destroy_challenge_choose,
:update_choose_question, :destroy, :crud_answer, :answer] :update_choose_question, :destroy, :crud_answer, :answer]
# before_action :allowed, except: [:index, :show, :edit_choose_question, :edit] # 关卡更新和操作的权限控制
before_action :update_allowed, except: [:index]
# 关卡访问的权限控制
before_action :shixun_access_allowed, only: [:index]
include ShixunsHelper include ShixunsHelper
include ChallengesHelper include ChallengesHelper
@ -149,7 +151,9 @@ class ChallengesController < ApplicationController
def index def index
uid_logger("identifier: #{params}") uid_logger("identifier: #{params}")
# 通过调试发现 这里includes(:games)性能会慢10倍 # 通过调试发现 这里includes(:games)性能会慢10倍
@challenges = @shixun.challenges.fields_for_list
@challenges = @shixun.challenges.fields_for_list.includes(:games).where("games.user_id" => current_user.id)
@editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0
@user = current_user @user = current_user
end end
@ -247,7 +251,6 @@ class ChallengesController < ApplicationController
# 关卡位置被修改,需要修改脚本 # 关卡位置被修改,需要修改脚本
script = modify_shixun_script @shixun, @shixun.evaluate_script script = modify_shixun_script @shixun, @shixun.evaluate_script
@shixun.update_column(:evaluate_script, script) @shixun.update_column(:evaluate_script, script)
end end
def index_up def index_up
@ -276,6 +279,9 @@ class ChallengesController < ApplicationController
def find_shixun def find_shixun
@shixun = Shixun.find_by_identifier(params[:shixun_identifier]) @shixun = Shixun.find_by_identifier(params[:shixun_identifier])
if !current_user.shixun_permission(@shixun)
tip_exception(403, "..")
end
end end
# 通用接口 # 通用接口
@ -295,9 +301,8 @@ class ChallengesController < ApplicationController
:standard_answer, :score, :difficult) :standard_answer, :score, :difficult)
end end
def allowed def update_allowed
# 实训为发布前,除实训的管理者外,其他人都不人都不允许访问 unless current_user.manager_of_shixun?(@shixun)
if !current_user.manager_of_shixun?(@shixun) && (@shixun.status < 1 || @shixun.hidden == 1)
raise Educoder::TipException.new(403, "..") raise Educoder::TipException.new(403, "..")
end end
end end

@ -11,7 +11,7 @@ class CoursesController < ApplicationController
render_error(ex.model.errors.full_messages.join(',')) render_error(ex.model.errors.full_messages.join(','))
end end
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups] before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner]
before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt, before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt,
:set_public_or_private, :search_teacher_candidate, :teachers, :set_public_or_private, :search_teacher_candidate, :teachers,
:top_banner, :left_banner, :add_teacher_popup, :add_teacher, :top_banner, :left_banner, :add_teacher_popup, :add_teacher,

@ -7,9 +7,18 @@ class DiscussesController < ApplicationController
page = params[:page].to_i page = params[:page].to_i
offset = page * LIMIT offset = page * LIMIT
# 总数,分页使用 # 总数,分页使用
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count if current_user.admin?
@discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil). @disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
includes(:user, :praise_tread).offset(offset) @discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s,
:root_id => nil).includes(:user, :praise_tread).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)
end
@current_user = current_user @current_user = current_user
end end
@ -23,8 +32,10 @@ class DiscussesController < ApplicationController
def create def create
begin begin
@discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type], :content => params[:content].gsub("&nbsp\;", "").strip, @discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type],
:user_id => current_user.id, :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id]) :content => params[:content].gsub("&nbsp\;", "").strip, :user_id => current_user.id,
:praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id],
:hidden => !current_user.admin?) # 管理员回复的能够显示
rescue Exception => e rescue Exception => e
uid_logger_error("create discuss failed : #{e.message}") uid_logger_error("create discuss failed : #{e.message}")
raise Educoder::TipException.new("评论异常") raise Educoder::TipException.new("评论异常")

@ -424,14 +424,9 @@ class ExerciseQuestionsController < ApplicationController
begin begin
choice_d_id = params[:choice_no].to_i # 选项的当前位置 choice_d_id = params[:choice_no].to_i # 选项的当前位置
question_choices = @exercise_question.exercise_choices question_choices = @exercise_question.exercise_choices
delete_answer = question_choices.find_choice_custom("choice_position",choice_d_id).first delete_answer = question_choices.find_by(choice_position: choice_d_id)
left_choice = question_choices.left_choice_choose("choice_position",choice_d_id) left_choices = question_choices.where("choice_position > ? ",choice_d_id)
if left_choice.present? left_choices.update_all("choice_position = choice_position - 1") if left_choices
left_choice.each do |p|
p.choice_position -= 1
p.save
end
end
if delete_answer.destroy if delete_answer.destroy
normal_status(0, "答案删除成功!") normal_status(0, "答案删除成功!")
else else
@ -450,13 +445,8 @@ class ExerciseQuestionsController < ApplicationController
begin begin
question_d_id = @exercise_question.question_number.to_i #问题的当前位置 question_d_id = @exercise_question.question_number.to_i #问题的当前位置
exercise_questions = @exercise.exercise_questions exercise_questions = @exercise.exercise_questions
left_question = exercise_questions.left_question_choose("question_number",question_d_id) left_questions = exercise_questions.where("question_number > ?", question_d_id)
if left_question.present? left_questions.update_all("question_number = question_number - 1") if left_questions
left_question.each do |q|
q.question_number -= 1
q.save
end
end
if @exercise_question.destroy if @exercise_question.destroy
normal_status(0, "问题删除成功!") normal_status(0, "问题删除成功!")
else else

@ -32,13 +32,13 @@ class ExercisesController < ApplicationController
@exercises_all = @course.exercises @exercises_all = @course.exercises
member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷 member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷
@current_user_ = current_user @current_user_ = current_user
@exercises_count = @exercises_all.count # 全部页面,需返回 @exercises_count = @exercises_all.size # 全部页面,需返回
@exercises_unpublish_counts = @exercises_all.exercise_by_status(1).count #未发布的试卷数 @exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数
@exercises_published_counts = @exercises_all.exercise_by_status([2,3]).count # 已发布的试卷数,包含已截止的 @exercises_published_counts = @exercises_all.exercise_by_status([2,3]).size # 已发布的试卷数,包含已截止的
@exercises_ended_counts = @exercises_all.exercise_by_status(3).count #已截止的试卷数 @exercises_ended_counts = @exercises_all.exercise_by_status(3).size #已截止的试卷数
# 课堂的学生人数 # 课堂的学生人数
@course_all_members = @course.students #当前课堂的全部学生 @course_all_members = @course.students #当前课堂的全部学生
@course_all_members_count = @course_all_members.count #当前课堂的学生数 @course_all_members_count = @course_all_members.size #当前课堂的学生数
@current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生 @current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生
# exercises的不同用户群体的显示 # exercises的不同用户群体的显示
@ -64,7 +64,7 @@ class ExercisesController < ApplicationController
@is_teacher_or = 0 @is_teacher_or = 0
@exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] @exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : []
end end
if @exercises.count > 0 if @exercises.size > 0
if params[:type].present? if params[:type].present?
choose_type = params[:type].to_i choose_type = params[:type].to_i
member_group_id = @current_student.first.try(:course_group_id).to_i member_group_id = @current_student.first.try(:course_group_id).to_i
@ -402,7 +402,7 @@ class ExercisesController < ApplicationController
:position => c.position, :position => c.position,
:challenge_id => c.challenge_id, :challenge_id => c.challenge_id,
:shixun_id => q.shixun_id, :shixun_id => q.shixun_id,
:question_score => q.question_score :question_score => c.question_score
} }
shixun_challenge_bank = exercise_bank_question.exercise_bank_shixun_challenges.new challenge_option shixun_challenge_bank = exercise_bank_question.exercise_bank_shixun_challenges.new challenge_option
shixun_challenge_bank.save shixun_challenge_bank.save
@ -729,7 +729,6 @@ class ExercisesController < ApplicationController
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置 if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置
exercise.exercise_group_settings.destroy_all exercise.exercise_group_settings.destroy_all
ex_unified = true ex_unified = true
notify_receiver_ids = @course.students.pluck(:user_id)
else else
ex_unified = false ex_unified = false
g_course.each do |i| g_course.each do |i|
@ -749,12 +748,11 @@ class ExercisesController < ApplicationController
end end
end end
notify_receiver_ids = @course.students.where(course_group_id: params[:group_ids]).pluck(:user_id) group_ids = params[:group_ids]
end end
else else
exercise.exercise_group_settings.destroy_all exercise.exercise_group_settings.destroy_all
ex_unified = true ex_unified = true
notify_receiver_ids = @course.students.pluck(:user_id)
end end
if exercise.end_time.blank? if exercise.end_time.blank?
e_time = ex_end_time e_time = ex_end_time
@ -775,7 +773,7 @@ class ExercisesController < ApplicationController
if exercise.course_acts.size == 0 if exercise.course_acts.size == 0
exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id) exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id)
end end
ExercisePublishNotifyJob.perform_later(exercise.id, notify_receiver_ids) ExercisePublishNotifyJob.perform_later(exercise.id, group_ids)
end end
end end
end end
@ -1334,7 +1332,7 @@ class ExercisesController < ApplicationController
#导出空白试卷 #导出空白试卷
def export_exercise def export_exercise
@exercise_questions = @exercise.exercise_questions.order("question_number ASC") @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf"
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
@ -1512,39 +1510,42 @@ class ExercisesController < ApplicationController
end end
def get_exercise_question_counts #获取试卷的问题数及总分数 def get_exercise_question_counts #获取试卷的问题数及总分数
exercise_questions = @exercise.exercise_questions.all exercise_questions = @exercise.exercise_questions
@exercise_ques_count = exercise_questions.count # 全部的题目数 @exercise_ques_count = exercise_questions.size # 全部的题目数
@exercise_ques_scores = exercise_questions.pluck(:question_score).sum @exercise_ques_scores = exercise_questions.pluck(:question_score).sum
#单选题的数量及分数 #单选题的数量及分数
exercise_single_ques = exercise_questions.find_by_custom("question_type",0) exercise_single_ques = exercise_questions.find_by_custom("question_type",0)
@exercise_single_ques_count = exercise_single_ques.all.count @exercise_single_ques_count = exercise_single_ques.size
@exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum @exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum
#多选题的数量及分数 #多选题的数量及分数
exercise_double_ques = exercise_questions.find_by_custom("question_type",1) exercise_double_ques = exercise_questions.find_by_custom("question_type",1)
@exercise_double_ques_count = exercise_double_ques.all.count @exercise_double_ques_count = exercise_double_ques.size
@exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum @exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum
# 判断题数量及分数 # 判断题数量及分数
exercise_ques_judge = exercise_questions.find_by_custom("question_type",2) exercise_ques_judge = exercise_questions.find_by_custom("question_type",2)
@exercise_ques_judge_count = exercise_ques_judge.all.count @exercise_ques_judge_count = exercise_ques_judge.size
@exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum @exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum
#填空题数量及分数 #填空题数量及分数
exercise_ques_null = exercise_questions.find_by_custom("question_type",3) exercise_ques_null = exercise_questions.find_by_custom("question_type",3)
@exercise_ques_null_count = exercise_ques_null.all.count @exercise_ques_null_count = exercise_ques_null.size
@exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum @exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum
#简答题数量及分数 #简答题数量及分数
exercise_ques_main = exercise_questions.find_by_custom("question_type",4) exercise_ques_main = exercise_questions.find_by_custom("question_type",4)
@exercise_ques_main_count = exercise_ques_main.all.count @exercise_ques_main_count = exercise_ques_main.size
@exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum @exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum
#实训题数量及分数 #实训题数量及分数
exercise_ques_shixun = exercise_questions.find_by_custom("question_type",5) exercise_ques_shixun = exercise_questions.find_by_custom("question_type",5)
@exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_count = exercise_ques_shixun.size
@exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum
@exercise_questions = @exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers)
end end
#获取用户有权限的分班 #获取用户有权限的分班

@ -270,7 +270,9 @@ class GamesController < ApplicationController
if @game.status == 2 if @game.status == 2
@game.update_attributes!(:answer_open => @answer.level) @game.update_attributes!(:answer_open => @answer.level)
else else
@game.update_attributes!(:answer_open => @answer.level, :answer_deduction => deduct_score) # 扣除总分计算
answer_deduction = challenge.challenge_answers.where("level <= #{@answer.level}").sum(:score)
@game.update_attributes!(:answer_open => @answer.level, :answer_deduction => answer_deduction)
end end
rescue Exception => e rescue Exception => e
@ -342,11 +344,10 @@ class GamesController < ApplicationController
@game.update_attribute(:test_sets_view, true) @game.update_attribute(:test_sets_view, true)
# 扣分记录 # 扣分记录
Grade.create(:user_id => current_user.id, :container_id => @game.id, :score => -@minus_grade, :container_type => "testSet") Grade.create(:user_id => current_user.id, :container_id => @game.id, :score => -@minus_grade, :container_type => "testSet")
@status = 0 max_query_index = @game.query_index.to_i
@message = "解锁成功!" testset_detail max_query_index, challenge
else else
@status = -1 tip_exception(-1, "本操作需要扣除#{ @minus_grade }金币,您的金币不够了")
@message = "本操作需要扣除#{ @minus_grade }金币,您的金币不够了"
end end
end end
@ -811,7 +812,7 @@ class GamesController < ApplicationController
# 评测测试机封装 # 评测测试机封装
def testset_detail max_query_index, challenge def testset_detail max_query_index, challenge
# 是否允许查看隐藏的测试集以前的power # 是否允许查看隐藏的测试集以前的power
@allowed_hidden_testset = @identity < User::EDU_GAME_MANAGER @allowed_hidden_testset = @identity < User::EDU_GAME_MANAGER || @game.test_sets_view #解锁的用户
if max_query_index > 0 if max_query_index > 0
uid_logger("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}") uid_logger("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}")

@ -59,7 +59,8 @@ class GraduationTasksController < ApplicationController
# 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品 # 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品
if @task.published? && (@user_course_identity < Course::STUDENT || if @task.published? && (@user_course_identity < Course::STUDENT ||
(@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 && (@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 &&
@task.status > 1 && @task.open_work)) ((!@task.allow_late && @task.status > 1) || (@task.allow_late && @task.late_time && @task.late_time < Time.now)) &&
(@task.open_work || @task.open_score)))
# 如有有分班则看分班内的学生,否则看所有学生的作品 # 如有有分班则看分班内的学生,否则看所有学生的作品
user_ids = user_ids =
if @user_course_identity < Course::STUDENT if @user_course_identity < Course::STUDENT
@ -117,6 +118,7 @@ class GraduationTasksController < ApplicationController
@work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}") @work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}")
end end
@view_work = @task.open_work || @user_course_identity < Course::STUDENT
@work_count = @work_list.count @work_count = @work_list.count
@work_excel = @work_list @work_excel = @work_list
@ -150,6 +152,7 @@ class GraduationTasksController < ApplicationController
end end
else else
@work_list = @work @work_list = @work
@view_work = false
@work_count = @work_list.count @work_count = @work_list.count
@all_work_count = @work_list.count @all_work_count = @work_list.count
respond_to do |format| respond_to do |format|

@ -24,8 +24,7 @@ class GraduationTopicsController < ApplicationController
end end
# 当前用户是否已经选过题 # 当前用户是否已经选过题
user_graduation_topics = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]) #6.12 -hs @user_selected = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]).count > 0 #6.12 -hs
@user_selected = user_graduation_topics.size > 0
## 分页参数 ## 分页参数
page = params[:page] || 1 page = params[:page] || 1
limit = params[:limit] || 15 limit = params[:limit] || 15
@ -173,7 +172,7 @@ class GraduationTopicsController < ApplicationController
member = @course.course_members.where(:user_id => @graduation_topic.tea_id).first member = @course.course_members.where(:user_id => @graduation_topic.tea_id).first
tip_exception("分班名称不能为空") if params[:course_group_name].blank? tip_exception("分班名称不能为空") if params[:course_group_name].blank?
course_group = CourseGroup.create(:name => params[:course_group_name], :course_id => @course.id) course_group = CourseGroup.create(:name => params[:course_group_name], :course_id => @course.id)
teacher_group = TeacherCourseGroup.create(:course_id => @course.id, :member_id => member.try(:id), teacher_group = TeacherCourseGroup.create(:course_id => @course.id, :course_member_id => member.try(:id),
:user_id => @graduation_topic.tea_id, :user_id => @graduation_topic.tea_id,
:course_group_id => course_group.try(:id)) :course_group_id => course_group.try(:id))
end end
@ -194,8 +193,8 @@ class GraduationTopicsController < ApplicationController
def student_select_topic def student_select_topic
user_unaccept_topics = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]) user_unaccept_topics = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1])
if user_unaccept_topics.size == 0 if user_unaccept_topics.size == 0
member_id = @course.course_members.find_by_user_id(current_user.id) member = @course.course_members.find_by_user_id(current_user.id)
StudentGraduationTopic.create(course_id: @course.id, user_id: current_user.id, member_id: member_id, StudentGraduationTopic.create(course_id: @course.id, user_id: current_user.id, course_member_id: member.try(:id),
graduation_topic_id: @graduation_topic.id) graduation_topic_id: @graduation_topic.id)
@graduation_topic.update_attribute(:status, 1) @graduation_topic.update_attribute(:status, 1)
normal_status("选题成功") normal_status("选题成功")

@ -13,6 +13,7 @@ class GraduationWorksController < ApplicationController
before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project, before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project,
:cancel_relate_project, :revise_attachment] :cancel_relate_project, :revise_attachment]
before_action :edit_duration, only: [:edit, :update] before_action :edit_duration, only: [:edit, :update]
before_action :open_work, only: [:show, :supply_attachments, :comment_list]
def new def new
if @task.task_type == 2 && @task.base_on_project if @task.task_type == 2 && @task.base_on_project
@ -432,11 +433,11 @@ class GraduationWorksController < ApplicationController
# 交叉评阅分配老师 # 交叉评阅分配老师
def assign_teacher def assign_teacher
tip_exception(-1, "user_id不能为空") if params[:user_id].nil? tip_exception(-1, "user_id不能为空") if params[:user_id].nil?
@work_assign_teacher = @work.graduation_work_comment_assignations.first @work_assign_teacher = @work.graduation_work_comment_assignations.find_by(user_id: params[:user_id])
if @work_assign_teacher if @work_assign_teacher.present?
# graduation_group_id: 已经是答辩组的需要 将答辩组清空 # graduation_group_id: 已经是答辩组的需要 将答辩组清空
@work_assign_teacher.update_attributes(user_id: params[:user_id], graduation_group_id: 0) @work_assign_teacher.update_attributes(graduation_group_id: 0)
else else
@work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(graduation_task_id: @task.id, @work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(graduation_task_id: @task.id,
user_id: params[:user_id], user_id: params[:user_id],
@ -489,6 +490,11 @@ class GraduationWorksController < ApplicationController
tip_exception("已过了修改时间") if @task.end_time && @task.end_time < Time.now tip_exception("已过了修改时间") if @task.end_time && @task.end_time < Time.now
end end
# 作品是否公开
def open_work
tip_exception(403,"没有操作权限") unless (@user_course_identity < Course::STUDENT || current_user == @work.user || @task.open_work)
end
def update_check work def update_check work
tip_exception("作品描述不能为空") if params[:description].blank? tip_exception("作品描述不能为空") if params[:description].blank?
if @task.task_type == 2 if @task.task_type == 2

@ -104,7 +104,7 @@ class HomeworkCommonsController < ApplicationController
@shixun = @homework.shixuns.take if @homework.homework_type == "practice" @shixun = @homework.shixuns.take if @homework.homework_type == "practice"
student_works = @homework.all_works student_works = @homework.all_works
@all_member_count = student_works.count @all_member_count = student_works.size
if @homework.publish_time.nil? || @homework.publish_time > Time.now if @homework.publish_time.nil? || @homework.publish_time > Time.now
@student_works = [] @student_works = []
respond_to do |format| respond_to do |format|
@ -121,28 +121,31 @@ class HomeworkCommonsController < ApplicationController
@work = @homework.user_work(current_user.id) @work = @homework.user_work(current_user.id)
# 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段
if @work.work_status > 0 && @homework.work_public && if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) &&
((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4) ((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4)
@student_works = student_works.where("user_id != #{@work.id}") @student_works = student_works.where("user_id != #{@work.user_id}")
# 匿评、申诉阶段只能看到分配给自己的匿评作品 # 匿评、申诉阶段只能看到分配给自己的匿评作品
elsif @work.work_status > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2
@is_evaluation = true @is_evaluation = true
@student_works = student_works.joins(:student_works_evaluation_distributions).where( @student_works = student_works.joins(:student_works_evaluation_distributions).where(
"student_works_evaluation_distributions.user_id = #{@current_user.id}") "student_works_evaluation_distributions.user_id = #{@current_user.id}")
else else
@student_works = [] @student_works = []
end end
@score_open = @homework.score_open && @work&.work_status.to_i > 0
elsif @user_course_identity < Course::STUDENT elsif @user_course_identity < Course::STUDENT
@student_works = @homework.teacher_works(@member) @student_works = @homework.teacher_works(@member)
@all_member_count = @student_works.count @all_member_count = @student_works.size
@score_open = true
elsif @user_course_identity > Course::STUDENT && @homework.work_public elsif @user_course_identity > Course::STUDENT && @homework.work_public
@student_works = student_works @student_works = student_works
@score_open = false
else else
@student_works = [] @student_works = []
end end
unless @student_works.size == 0 unless @student_works.blank?
# 教师评阅搜索 0: 未评, 1 已评 # 教师评阅搜索 0: 未评, 1 已评
unless params[:teacher_comment].blank? unless params[:teacher_comment].blank?
student_work_ids = StudentWorksScore.where(student_work_id: @student_works.map(&:id)).pluck(:student_work_id) student_work_ids = StudentWorksScore.where(student_work_id: @student_works.map(&:id)).pluck(:student_work_id)
@ -187,12 +190,13 @@ class HomeworkCommonsController < ApplicationController
# 分页参数 # 分页参数
page = params[:page] || 1 page = params[:page] || 1
limit = params[:limit] || 20 limit = params[:limit] || 20
@student_works = @student_works.page(page).per(limit).includes(:student_works_scores) @student_works = @student_works.page(page).per(limit)
if @homework.homework_type == "practice" if @homework.homework_type == "practice"
@student_works = @student_works.includes(user: :user_extension, myshixun: :games) @student_works = @student_works.includes(:student_works_scores, user: :user_extension, myshixun: :games)
else else
@student_works = @student_works.includes(:student_works_scores, :project, user: :user_extension) @student_works = @student_works.includes(:student_works_scores, :project, user: :user_extension)
end end
# @members = @course.students.where(user_id: @student_works.pluck(:user_id)).includes(:course_group)
end end
respond_to do |format| respond_to do |format|
format.json format.json

@ -156,14 +156,10 @@ class PollQuestionsController < ApplicationController
begin begin
answer_d_id = params[:answer_no].to_i # 答案的当前位置 answer_d_id = params[:answer_no].to_i # 答案的当前位置
poll_answers = @poll_question.poll_answers poll_answers = @poll_question.poll_answers
delete_answer = poll_answers.find_answer_by_custom("answer_position",answer_d_id).first delete_answer = poll_answers.find_by(answer_position: answer_d_id)
left_answer = poll_answers.left_answer_choose("answer_position",answer_d_id) left_answers = poll_answers.where("answer_position > ?",answer_d_id)
if left_answer.present? left_answers.update_all("answer_position = answer_position - 1") if left_answers
left_answer.each do |p|
p.answer_position -= 1
p.save
end
end
if delete_answer.destroy if delete_answer.destroy
normal_status(0, "答案删除成功!") normal_status(0, "答案删除成功!")
else else

@ -263,7 +263,6 @@ class PollsController < ApplicationController
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置 if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置
poll.poll_group_settings.destroy_all poll.poll_group_settings.destroy_all
poll_unified = true poll_unified = true
notify_student_ids = @course.students.pluck(:user_id)
else else
poll_unified = false poll_unified = false
g_course.each do |i| g_course.each do |i|
@ -282,13 +281,11 @@ class PollsController < ApplicationController
new_poll_group.save new_poll_group.save
end end
end end
group_ids = params[:group_ids]
notify_student_ids = @course.students.where(course_group_id: params[:group_ids]).pluck(:user_id)
end end
else else
poll.poll_group_settings.destroy_all poll.poll_group_settings.destroy_all
poll_unified = true poll_unified = true
notify_student_ids = @course.students.pluck(:user_id)
end end
if poll.end_time.blank? if poll.end_time.blank?
e_time = ex_end_time e_time = ex_end_time
@ -309,7 +306,7 @@ class PollsController < ApplicationController
if poll.course_acts.size == 0 if poll.course_acts.size == 0
poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id) poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id)
end end
PollPublishNotifyJob.perform_later(poll.id, notify_student_ids) PollPublishNotifyJob.perform_later(poll.id, group_ids)
end end
end end
normal_status(0, "问卷发布成功!") normal_status(0, "问卷发布成功!")
@ -1184,7 +1181,7 @@ class PollsController < ApplicationController
def check_poll_commit_result def check_poll_commit_result
poll_status = @poll.get_poll_status(current_user.id) poll_status = @poll.get_poll_status(current_user.id)
commit_poll_user = @poll.poll_users.find_by_group_ids(current_user.id).commit_by_status(1) #当前用户已提交问卷的 commit_poll_user = @poll.poll_users.find_by_group_ids(current_user.id).commit_by_status(1) #当前用户已提交问卷的
unless @user_course_identity < Course::STUDENT || (@poll.show_result && poll_status == 3 && commit_poll_user.present?) unless (@user_course_identity < Course::STUDENT) || ((@poll.show_result == 1) && (poll_status == 3) && commit_poll_user.present?)
normal_status(-1,"没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的 normal_status(-1,"没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的
end end
end end

@ -266,11 +266,12 @@ class QuestionBanksController < ApplicationController
def quote_gtopic_bank topic, course def quote_gtopic_bank topic, course
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
new_topic = GraduationTopic.new new_topic = GraduationTopic.new
new_topic.attributes = topic.attributes.dup.except("id", "course_id", "user_id", "graduation_topic_id", new_topic.attributes = topic.attributes.dup.except("id", "course_id", "user_id", "graduation_topic_id", "quotes",
"course_list_id", "gtopic_bank_id", "created_at", "updated_at") "course_list_id", "gtopic_bank_id", "created_at", "updated_at")
new_topic.course_id = course.id new_topic.course_id = course.id
new_topic.gtopic_bank_id = topic.id new_topic.gtopic_bank_id = topic.id
new_topic.user_id = current_user.id new_topic.user_id = current_user.id
new_topic.tea_id = current_user.id
new_topic.save new_topic.save
topic.attachments.each.try(:each) do |attachment| topic.attachments.each.try(:each) do |attachment|

@ -2,8 +2,9 @@ class ShixunsController < ApplicationController
before_action :require_login, except: [:download_file, :index, :menus] before_action :require_login, except: [:download_file, :index, :menus]
before_action :check_auth, except: [:download_file, :index] before_action :check_auth, except: [:download_file, :index]
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:departments, :apply_shixun_mirror, :get_mirror_script, :download_file] :propaedeutics, :departments, :apply_shixun_mirror,
:get_mirror_script, :download_file]
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy] before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
@ -488,17 +489,19 @@ class ShixunsController < ApplicationController
tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}") tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}")
end end
current_myshixun = @shixun.current_myshixun(current_user.id) current_myshixun = @shixun.current_myshixun(current_user.id)
min_challenges = @shixun.challenges.pluck(:id , :st)
if current_myshixun if current_myshixun
games = current_myshixun.games
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置 # 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置
if current_myshixun.games.count != @shixun.challenges_count || if games.size != min_challenges.size || games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first}
current_myshixun.games.reorder(:challenge_id).pluck(:challenge_id) != @shixun.challenges.reorder(:id).pluck(:id)
uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}")
# 这里页面弹框要收到 当前用户myshixun的identifier. # 这里页面弹框要收到 当前用户myshixun的identifier.
tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game")
end end
# 如果存在实训,则直接进入实训 # 如果存在实训,则直接进入实训
@current_task = current_myshixun.current_task @current_task = current_myshixun.current_task(games)
else else
# 如果未创建关卡一定不能开启实训否则TPI没法找到当前的关卡 # 如果未创建关卡一定不能开启实训否则TPI没法找到当前的关卡
if @shixun.challenges_count == 0 if @shixun.challenges_count == 0
@ -506,17 +509,17 @@ class ShixunsController < ApplicationController
end end
# 判断实训是否全为选择题 # 判断实训是否全为选择题
is_choice_type = @shixun.is_choice_type? is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count)
if !is_choice_type if !is_choice_type
commit = GitService.commits(repo_path: @repo_path).try(:first) commit = GitService.commits(repo_path: @repo_path).try(:first)
Rails.logger.info("First comit########{commit}") uid_logger("First comit########{commit}")
tip_exception("开启实战前请先在版本库中提交代码") if commit.blank? tip_exception("开启实战前请先在版本库中提交代码") if commit.blank?
commit_id = commit["id"] commit_id = commit["id"]
end end
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
#cloud_bridge = edu_setting('cloud_bridge') cloud_bridge = edu_setting('cloud_bridge')
myshixun_identifier = generate_identifier Myshixun, 10 myshixun_identifier = generate_identifier Myshixun, 10
myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier, myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier,
modify_time: @shixun.modify_time, reset_time: @shixun.reset_time, modify_time: @shixun.modify_time, reset_time: @shixun.reset_time,
@ -528,29 +531,34 @@ class ShixunsController < ApplicationController
# fork仓库 # fork仓库
project_fork(myshixun, @repo_path, current_user.login) project_fork(myshixun, @repo_path, current_user.login)
#rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path ) rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path )
#uid_logger("start openGameInstance") uid_logger("start openGameInstance")
#uri = "#{cloud_bridge}/bridge/game/openGameInstance" uri = "#{cloud_bridge}/bridge/game/openGameInstance"
#logger.info("end openGameInstance") logger.info("end openGameInstance")
#params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last} params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last}
#uid_logger("openGameInstance params is #{params}") uid_logger("openGameInstance params is #{params}")
# res = interface_post uri, params, 83, "实训云平台繁忙繁忙等级83" interface_post uri, params, 83, "实训云平台繁忙繁忙等级83"
end end
# 其它创建关卡等操作 # 其它创建关卡等操作
challenges = @shixun.challenges challenges = @shixun.challenges
# 之所以增加user_id是为了方便统计查询性能 # 之所以增加user_id是为了方便统计查询性能
challenges.each_with_index do |challenge, index| game_attrs = %i[challenge_id myshixun_id status user_id open_time identifier modify_time created_at updated_at]
status = (index == 0 ? 0 : 3) Game.bulk_insert(*game_attrs) do |worker|
game_identifier = generate_identifier(Game, 12) base_attr = { myshixun_id: myshixun.id, user_id: myshixun.user_id }
Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id, challenges.each_with_index do |challenge, index|
:open_time => Time.now, :identifier => game_identifier, :modify_time => challenge.modify_time) status = (index == 0 ? 0 : 3)
game_identifier = generate_identifier(Game, 12)
worker.add(base_attr.merge(challenge_id: challenge.id, status: status, open_time: Time.now,
identifier: game_identifier, modify_time: challenge.modify_time))
end
end end
# REDO:开启实训时更新关联作品的状态 # REDO:开启实训时更新关联作品的状态
# TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做 # TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做
HomeworksService.new.update_myshixun_work_status myshixun # HomeworksService.new.update_myshixun_work_status myshixun
UpdateMyshixunWorkStatusJob.perform_later(myshixun.id)
@current_task = myshixun.current_task @current_task = myshixun.current_task(myshixun.games)
uid_logger("## shixun exec: myshixun id is #{myshixun.id}") uid_logger("## shixun exec: myshixun id is #{myshixun.id}")
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
@ -559,10 +567,8 @@ class ShixunsController < ApplicationController
end end
end end
end end
end end
# gameID 及实训ID # gameID 及实训ID
# status: 0 , 1 申请过, 2实训关卡路径未填 3 实训标签未填, 4 实训未创建关卡 # status: 0 , 1 申请过, 2实训关卡路径未填 3 实训标签未填, 4 实训未创建关卡
def publish def publish
@ -617,11 +623,22 @@ class ShixunsController < ApplicationController
end end
def add_collaborators def add_collaborators
raise("搜索内容不能为空") unless params[:search] member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")"
member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" user_name = "%#{params[:user_name].to_s.strip}%"
condition = "%#{params[:search].strip}%".gsub(" ","") school_name = "%#{params[:school_name].to_s.strip}%"
@users = User.where("id not in #{member_ids} and status = 1 and LOWER(concat(lastname, firstname, login, mail, nickname)) LIKE '#{condition}'") if user_name.present? || school_name.present?
end @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND
LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE
'#{school_name}'")
else
@users = User.none
end
page = params[:page] || 1
limit = params[:limit] || 20
@users_count = @users.count
@users = @users.page(page).per(limit)
end
def shixun_members_added def shixun_members_added
raise("user_ids 不能为空!") if params[:user_ids].blank? raise("user_ids 不能为空!") if params[:user_ids].blank?
@ -662,14 +679,14 @@ class ShixunsController < ApplicationController
limit = params[:limit] || 20 limit = params[:limit] || 20
if params[:search] if params[:search]
search = "%#{params[:search].to_s.strip.downcase}%" search = "%#{params[:search].to_s.strip.downcase}%"
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) WHERE m.course_id = c.id AND m.role in (1,2,3)
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0 AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0
AND c.name like '#{search}' ").map(&:id) AND c.name like '#{search}' ").map(&:id)
else else
course_ids = Course.find_by_sql("SELECT c.id, c.name FROM courses c, members m, member_roles mr course_ids = Course.find_by_sql("SELECT c.id, c.name FROM courses c, course_members m
WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) WHERE m.course_id = c.id AND m.role in (1,2,3)
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
end end
@ -681,7 +698,7 @@ class ShixunsController < ApplicationController
# 将实训发送到课程 # 将实训发送到课程
def send_to_course def send_to_course
@course = Course.find(params[:course_id]) @course = Course.find(params[:course_id])
homework = HomeworksService.new.create_homework shixun, @course, nil, current_user homework = HomeworksService.new.create_homework @shixun, @course, nil, current_user
end end
# 二维码扫描下载 # 二维码扫描下载
@ -715,10 +732,6 @@ private
normal_status(404, "...") normal_status(404, "...")
return return
end end
if !current_user.shixun_permission(@shixun)
tip_exception(403, "..")
end
end end
def find_repo_name def find_repo_name

@ -25,7 +25,7 @@ class StudentWorksController < ApplicationController
before_action :require_score_id, only: [:destroy_score, :add_score_reply, :appeal_anonymous_score, :deal_appeal_score, :cancel_appeal] before_action :require_score_id, only: [:destroy_score, :add_score_reply, :appeal_anonymous_score, :deal_appeal_score, :cancel_appeal]
before_action :is_evaluation, only: [:show, :supply_attachments] before_action :is_evaluation, :open_work, only: [:show, :supply_attachments]
def new def new
uid_logger("#######new current_user : 1111") uid_logger("#######new current_user : 1111")
@ -434,7 +434,7 @@ class StudentWorksController < ApplicationController
# 用户最大评测次数 # 用户最大评测次数
if @games if @games
@user_evaluate_count = @games.sum(:evaluate_count) @user_evaluate_count = @games.pluck(:evaluate_count).sum
@games = @games.includes(:challenge, :game_codes, :outputs) @games = @games.includes(:challenge, :game_codes, :outputs)
else else
@user_evaluate_count = 0 @user_evaluate_count = 0
@ -450,7 +450,7 @@ class StudentWorksController < ApplicationController
@games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun @games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun
# 用户最大评测次数 # 用户最大评测次数
@user_evaluate_count = @games.sum(:evaluate_count) if @games @user_evaluate_count = @games.pluck(:evaluate_count).sum if @games
# 图形效率图的数据 # 图形效率图的数据
@echart_data = student_efficiency(@homework, @work) @echart_data = student_efficiency(@homework, @work)
@myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id } @myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id }
@ -704,6 +704,11 @@ class StudentWorksController < ApplicationController
[3, 4].include?(@homework.homework_detail_manual.comment_status) [3, 4].include?(@homework.homework_detail_manual.comment_status)
end end
# 作品是否公开
def open_work
tip_exception(403,"没有操作权限") unless (@user_course_identity < Course::STUDENT || current_user == @work.user || @homework.work_public || @is_evaluation)
end
def allow_add_score def allow_add_score
# 老师始终有评阅权限,匿评阶段内,学生对分配给该学生的作品有评阅权限 # 老师始终有评阅权限,匿评阶段内,学生对分配给该学生的作品有评阅权限
tip_exception(403, "没有权限") unless allow_score(@homework, @user_course_identity, current_user.id, @work) tip_exception(403, "没有权限") unless allow_score(@homework, @user_course_identity, current_user.id, @work)

@ -164,8 +164,8 @@ class SubjectsController < ApplicationController
end end
def choose_course def choose_course
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) WHERE m.course_id = c.id AND m.role in (1,2,3)
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
@courses = Course.where(id: course_ids) @courses = Course.where(id: course_ids)
@none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id) @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id)

@ -232,7 +232,7 @@ module CoursesHelper
course.course_groups.includes(:course_members) course.course_groups.includes(:course_members)
end end
group_info = [] group_info = []
if course_groups.count > 0 if !course_groups.blank?
course_groups.each do |group| course_groups.each do |group|
group_info << {course_group_id: group.id, group_group_name: group.name, count: group.course_members_count} group_info << {course_group_id: group.id, group_group_name: group.name, count: group.course_members_count}
end end

@ -13,7 +13,8 @@ module ExercisesHelper
ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum
end end
if ques_score == q.question_score #满分作答为正确 if ques_score >= q.question_score #满分作答为正确
ques_score = q.question_score
stand_answer = 1 stand_answer = 1
elsif ques_score > 0.0 #部分作答 elsif ques_score > 0.0 #部分作答
stand_answer = 2 stand_answer = 2
@ -35,7 +36,8 @@ module ExercisesHelper
exercise_sub_status.each do |s| exercise_sub_status.each do |s|
sub_answer = s.exercise_answers.search_answer_users("user_id",user_id) #主观题只有一个回答 sub_answer = s.exercise_answers.search_answer_users("user_id",user_id) #主观题只有一个回答
if sub_answer.present? && sub_answer.first.score >= 0.0 if sub_answer.present? && sub_answer.first.score >= 0.0
if s.question_score == sub_answer.first.score
if s.question_score <= sub_answer.first.score
stand_status = 1 stand_status = 1
else else
stand_status = 2 stand_status = 2
@ -44,7 +46,7 @@ module ExercisesHelper
sub_answer_score = sub_answer.first.score sub_answer_score = sub_answer.first.score
else else
stand_status = 0 stand_status = 0
sub_answer_score = 0.0 sub_answer_score = nil
end end
sub_score = { sub_score = {
@ -52,7 +54,7 @@ module ExercisesHelper
"q_type":s.question_type, "q_type":s.question_type,
"q_position":s.question_number, "q_position":s.question_number,
"stand_status":stand_status, "stand_status":stand_status,
"user_score":sub_answer_score.round(1).to_s "user_score":sub_answer_score.present? ? sub_answer_score.round(1).to_s : nil
} }
@ex_sub_array.push(sub_score) @ex_sub_array.push(sub_score)
end end
@ -419,8 +421,10 @@ module ExercisesHelper
if game.present? if game.present?
exercise_cha_score = 0.0 exercise_cha_score = 0.0
answer_status = 0 answer_status = 0
if game.status == 2 && game.final_score >= 0 # if game.status == 2 && game.final_score >= 0
exercise_cha_score = exercise_cha.question_score #每一关卡的得分 if game.final_score > 0
exercise_cha_score = game.real_score(exercise_cha.question_score)
# exercise_cha_score = exercise_cha.question_score #每一关卡的得分
answer_status = 1 answer_status = 1
end end
ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id)
@ -437,7 +441,7 @@ module ExercisesHelper
:exercise_question_id => q.id, :exercise_question_id => q.id,
:exercise_shixun_challenge_id => exercise_cha.id, :exercise_shixun_challenge_id => exercise_cha.id,
:user_id => user.id, :user_id => user.id,
:score => exercise_cha_score, :score => exercise_cha_score.round(1),
:answer_text => code, :answer_text => code,
:status => answer_status :status => answer_status
} }
@ -504,15 +508,14 @@ module ExercisesHelper
current_user_group_name = course_group.first.name if course_group.present? current_user_group_name = course_group.first.name if course_group.present?
end end
teacher_review = ex_user.subjective_score < 0.0 ? false : true teacher_review = ex_user.subjective_score < 0.0 ? false : true
if ex_user_exercise_status != 3 || commit_status != 1 #试卷未截止或用户未提交 if (user_status == 0 && commit_status == 1) || (user_status == 1 && ex_user_exercise_status == 3 && commit_status == 1) #老师都可以看,学生,需在试卷已提交,且已截止的情况下看
# if (user_status != 0 && ex_user_exercise_status != 3)|| commit_status == 0 #不为教师,且试卷未截止;当前用户未提交 不显示分数
ex_object_score = nil
ex_subject_score = nil
score = nil
else
ex_object_score = ex_user.objective_score < 0.0 ? 0.0 : ex_user.objective_score.round(1).to_s ex_object_score = ex_user.objective_score < 0.0 ? 0.0 : ex_user.objective_score.round(1).to_s
ex_subject_score = ex_user.subjective_score < 0.0 ? nil : ex_user.subjective_score.round(1).to_s ex_subject_score = ex_user.subjective_score < 0.0 ? nil : ex_user.subjective_score.round(1).to_s
score = ex_user.score.present? ? ex_user.score.round(1).to_s : 0.0.to_s score = ex_user.score.present? ? ex_user.score.round(1).to_s : 0.0.to_s
else
ex_object_score = nil
ex_subject_score = nil
score = nil
end end
{ {
@ -624,16 +627,21 @@ module ExercisesHelper
#学生的分数状态及回答的内容 #学生的分数状态及回答的内容
def user_question_answers(q,ex_answerer_id,student_status,is_teacher_or,ex_status,ques_type,ex_type) def user_question_answers(q,ex_answerer_id,student_status,is_teacher_or,ex_status,ques_type,ex_type)
answered_content = [] answered_content = []
user_score = 0.0 user_score = nil
shixun_type = 0 shixun_type = 0
question_comment = [] question_comment = []
if q.question_type == 5 if ques_type == 5
exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id) exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id)
else else
exercise_answers = q.exercise_answers.search_exercise_answer("user_id",ex_answerer_id) #试卷用户的回答 exercise_answers = q.exercise_answers.search_exercise_answer("user_id",ex_answerer_id) #试卷用户的回答
end end
if student_status == 2 #当前为老师,或为学生且已提交 if student_status == 2 #当前为老师,或为学生且已提交
user_score = exercise_answers.score_reviewed.pluck(:score).sum user_score_pre = exercise_answers.score_reviewed
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil
end
if user_score.present? && (user_score > q.question_score)
user_score = q.question_score
end end
if ques_type <= 2 if ques_type <= 2
answered_content = exercise_answers.pluck(:exercise_choice_id) answered_content = exercise_answers.pluck(:exercise_choice_id)
@ -661,7 +669,7 @@ module ExercisesHelper
question_comment = q.exercise_answer_comments.search_answer_comments("exercise_answer_id",q_answer_id) question_comment = q.exercise_answer_comments.search_answer_comments("exercise_answer_id",q_answer_id)
end end
{ {
"user_score": user_score.round(1), "user_score": (user_score.present? ? user_score.round(1).to_s : nil),
"answered_content":answered_content, "answered_content":answered_content,
"shixun_type":shixun_type, "shixun_type":shixun_type,
"question_comment":question_comment "question_comment":question_comment

@ -65,7 +65,7 @@ module HomeworkCommonsHelper
# 作业统一设置、游客身份、超级管理员、分班权限不限的老师身份 # 作业统一设置、游客身份、超级管理员、分班权限不限的老师身份
if homework_common.unified_setting || identity > Course::STUDENT || identity == Course::ADMIN || if homework_common.unified_setting || identity > Course::STUDENT || identity == Course::ADMIN ||
(identity < Course::STUDENT && teacher_course_groups.size == 0) (identity < Course::STUDENT && teacher_course_groups.blank?)
case ho_detail_manual.comment_status case ho_detail_manual.comment_status
when 0 when 0
status << "未发布" status << "未发布"

@ -3,8 +3,8 @@ module PollsHelper
#获取试卷的已答/未答人数 #获取试卷的已答/未答人数
def get_poll_answers(poll_users) def get_poll_answers(poll_users)
@commit_poll_users = poll_users.commit_by_status(1) #当前老师的全部学生中已提交的 @commit_poll_users = poll_users.commit_by_status(1) #当前老师的全部学生中已提交的
@poll_answers = @commit_poll_users.present? ? @commit_poll_users.count : 0 #表示已经提交了的用户 @poll_answers = @commit_poll_users.present? ? @commit_poll_users.size : 0 #表示已经提交了的用户
course_all_members_count = poll_users.present? ? poll_users.count : 0 course_all_members_count = poll_users.present? ? poll_users.size : 0
@poll_unanswers = (course_all_members_count - @poll_answers) @poll_unanswers = (course_all_members_count - @poll_answers)
end end

@ -54,13 +54,13 @@ module StudentWorksHelper
objects = objects =
myshixuns.map do |myshixun| myshixuns.map do |myshixun|
# 评测次数 # 评测次数
evaluate_count = myshixun.games.sum(:evaluate_count) evaluate_count = myshixun.games.pluck(:evaluate_count).sum
# 获取最大评测次数 # 获取最大评测次数
max_evaluate_count = (evaluate_count > max_evaluate_count ? evaluate_count : max_evaluate_count) max_evaluate_count = (evaluate_count > max_evaluate_count ? evaluate_count : max_evaluate_count)
# 通关耗时 # 通关耗时
pass_consume_time = (myshixun.games.where(status: 2).pluck(:cost_time).sum / 60.0) pass_consume_time = (myshixun.total_cost_time / 60.0)
# 总耗时 # 总耗时
all_time = (myshixun.games.sum(:cost_time) / 60.0) all_time = (myshixun.games.pluck(:cost_time).sum / 60.0)
# 通关得分 # 通关得分
user_total_score = myshixun.total_score.to_i user_total_score = myshixun.total_score.to_i
# 耗时,保留2位小数 # 耗时,保留2位小数
@ -145,7 +145,7 @@ module StudentWorksHelper
else else
user_name = message_user.real_name user_name = message_user.real_name
user_login = message_user.login user_login = message_user.login
image_url = url_to_avatar(score.user) image_url = url_to_avatar(message_user)
end end
{user_name: user_name, user_login: user_login, user_image_url: image_url} {user_name: user_name, user_login: user_login, user_image_url: image_url}
end end

@ -2,11 +2,20 @@
class ExercisePublishNotifyJob < ApplicationJob class ExercisePublishNotifyJob < ApplicationJob
queue_as :notify queue_as :notify
def perform(exercise_id, receiver_ids) def perform(exercise_id, group_ids)
exercise = Exercise.find_by(id: exercise_id) exercise = Exercise.find_by(id: exercise_id)
return if exercise.blank? return if exercise.blank?
user = exercise.user user = exercise.user
if group_ids.present?
students = course.students.where(course_group_id: group_ids)
subquery = course.teacher_course_groups.where(course_group_id: group_ids).select(:course_member_id)
teachers = course.teachers.where(id: subquery)
else
students = course.students
teachers = course.teachers
end
attrs = %i[ attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type user_id trigger_user_id container_id container_type parent_container_id parent_container_type
belong_container_id belong_container_type viewed tiding_type created_at updated_at belong_container_id belong_container_type viewed tiding_type created_at updated_at
@ -19,14 +28,14 @@ class ExercisePublishNotifyJob < ApplicationJob
viewed: 0, tiding_type: 'Exercise' viewed: 0, tiding_type: 'Exercise'
} }
Tiding.bulk_insert(*attrs) do |worker| Tiding.bulk_insert(*attrs) do |worker|
teacher_ids = exercise.course.teachers.pluck(:user_id) teacher_ids = teachers.pluck(:user_id)
unless exercise.tidings.exists?(parent_container_type: 'ExercisePublish', user_id: teacher_ids) unless exercise.tidings.exists?(parent_container_type: 'ExercisePublish', user_id: teacher_ids)
exercise.course.teachers.find_each do |teacher| teacher_ids.find_each do |user_id|
worker.add same_attrs.merge(user_id: teacher.user_id) worker.add same_attrs.merge(user_id: user_id)
end end
end end
receiver_ids.each do |user_id| students.pluck(:user_id).each do |user_id|
worker.add same_attrs.merge(user_id: user_id) worker.add same_attrs.merge(user_id: user_id)
end end
end end

@ -0,0 +1,39 @@
# 毕设任务的交叉评阅分配
class GraduationTaskCrossCommentJob < ApplicationJob
queue_as :evaluation_comment
def perform(graduation_task_id)
task = GraduationTask.find_by(id: graduation_task_id)
return if task.blank?
course = task.course
task.graduation_task_group_assignations.each do |assignation|
graduation_group = assignation.graduation_group
assign_group = assignation.assign_group
if graduation_group.present? && assign_group.present?
course_group_ids = course.teacher_course_groups.where(course_member_id: graduation_group.course_members.pluck(:id)).pluck(:course_group_id)
graduation_works = task.graduation_works.where(user_id: course.course_members.where(:course_group_id => course_group_ids).map(&:user_id),
work_status: [1, 2])
if assign_group.course_members.count <= task.comment_num
graduation_works.each do |work|
assign_group.course_members.each do |member|
work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(
graduation_group_id: assign_group.id, user_id: member.user_id, graduation_task_id: task.id)
end
end
else
member_user_ids = assign_group.course_members.pluck(:user_id)
count = 0
graduation_works.each do |work|
for i in 1 .. task.comment_num
assign_user_id = member_user_ids[count % member_user_ids.size]
work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(
graduation_group_id: assign_group.id, user_id: assign_user_id, graduation_task_id: task.id)
count += 1
end
end
end
end
end
end
end

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

@ -0,0 +1,33 @@
class HomeworkAbsencePenaltyCalculationJob < ApplicationJob
queue_as :score
def perform(homework_common_id)
homework_common = HomeworkCommon.find_by(id: homework_common_id)
return if homework_common.blank?
#计算缺评扣分 参与匿评
work_ids = homework_common.student_works.has_committed.pluck(:id)
homework_detail_manual = homework_common.homework_detail_manual
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.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
end
# 未参与匿评
if homework_detail_manual.no_anon_penalty == 0
all_dis_eva = StudentWorksEvaluationDistribution.where(student_work_id: work_ids)
has_sw_count = all_dis_eva.select("distinct user_id").count
anon_count = all_dis_eva.count / has_sw_count
homework_common.student_works.where("work_status != 0").each do |student_work|
if student_work.user.student_works_evaluation_distributions.where(student_work_id: work_ids).count == 0
student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count
student_work.save
end
end
end
end
end

@ -0,0 +1,28 @@
# 匿评申诉开启时给分配了匿评的学生发消息
class HomeworkAnonymousAppealStartNotifyJob < ApplicationJob
queue_as :notify
def perform(homework_common_id)
homework = HomeworkCommon.find_by(id: homework_common_id)
return if homework.blank?
eva_distribution = StudentWorksEvaluationDistribution.where(student_work_id: homework.student_works.pluck(:id))
attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
belong_container_id belong_container_type viewed tiding_type created_at updated_at
]
same_attrs = {
trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon',
parent_container_id: homework.id, parent_container_type: 'AnonymousAppeal',
belong_container_id: homework.course_id, belong_container_type: 'Course',
viewed: 0, tiding_type: 'HomeworkCommon'
}
Tiding.bulk_insert(*attrs) do |worker|
eva_distribution.pluck(:user_id).uniq.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end

@ -24,7 +24,7 @@ class HomeworkCommonPushNotifyJob < ApplicationJob
same_attrs = { same_attrs = {
trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon', trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon',
parent_container_id: homework.id, parent_container_type: 'HomeworkPublish', parent_container_id: homework.id, parent_container_type: 'HomeworkPublish',
belong_container_id: task.course_id, belong_container_type: 'Course', belong_container_id: homework.course_id, belong_container_type: 'Course',
viewed: 0, tiding_type: 'HomeworkCommon' viewed: 0, tiding_type: 'HomeworkCommon'
} }
Tiding.bulk_insert(*attrs) do |worker| Tiding.bulk_insert(*attrs) do |worker|

@ -0,0 +1,48 @@
class HomeworkEvaluationCommentAssginJob < ApplicationJob
queue_as :evaluation_comment
def get_assigned_homeworks(student_works, n, index)
student_works += student_works
student_works[index + 1..index + n]
end
def perform(homework_common_id)
homework_common = HomeworkCommon.find_by(id: homework_common_id)
return if homework_common.blank?
homework_detail_manual = homework_common.homework_detail_manual
if homework_common.homework_type == "group"
student_works = homework_common.student_works.where("work_status != 0").group(:group_id)
student_work_projects = homework_common.student_works.where("work_status != 0").shuffle
student_work_projects.each do |pro_work|
n = homework_detail_manual.evaluation_num
n = (n < student_works.length && n != -1) ? n : student_works.length - 1
work_index = -1
student_works.each_with_index do |stu_work, stu_index|
if stu_work.group_id.to_i == pro_work.group_id.to_i
work_index = stu_index
end
end
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
end
else
student_works = homework_common.student_works.has_committed
student_works = student_works.shuffle
student_works.each_with_index do |work, index|
user = work.user
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
end
end
end
end

@ -0,0 +1,30 @@
class HomeworkEvaluationStartNotifyJob < ApplicationJob
queue_as :notify
def perform(homework_common_id, content)
homework = HomeworkCommon.find_by(id: homework_common_id)
return if homework.blank?
course = homework.course
members = content.blank? ? course.course_members : course.teachers
tiding_type = content.blank? ? "HomeworkCommon" : "System"
attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
belong_container_id belong_container_type viewed tiding_type extra created_at updated_at
]
same_attrs = {
trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon',
parent_container_id: homework.id, parent_container_type: 'AnonymousComment',
belong_container_id: homework.course_id, belong_container_type: 'Course',
viewed: 0, tiding_type: tiding_type, extra: content
}
Tiding.bulk_insert(*attrs) do |worker|
member_ids = members.pluck(:user_id).uniq
member_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end

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

@ -2,10 +2,20 @@
class PollPublishNotifyJob < ApplicationJob class PollPublishNotifyJob < ApplicationJob
queue_as :notify queue_as :notify
def perform(poll_id, receiver_ids) def perform(poll_id, group_ids)
poll = Poll.find_by(id: poll_id) poll = Poll.find_by(id: poll_id)
return if poll.blank? return if poll.blank?
user = poll.user user = poll.user
course = poll.course
if group_ids.present?
students = course.students.where(course_group_id: group_ids)
subquery = course.teacher_course_groups.where(course_group_id: group_ids).select(:course_member_id)
teachers = course.teachers.where(id: subquery)
else
students = course.students
teachers = course.teachers
end
attrs = %i[ attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type user_id trigger_user_id container_id container_type parent_container_id parent_container_type
@ -19,14 +29,14 @@ class PollPublishNotifyJob < ApplicationJob
viewed: 0, tiding_type: 'Poll' viewed: 0, tiding_type: 'Poll'
} }
Tiding.bulk_insert(*attrs) do |worker| Tiding.bulk_insert(*attrs) do |worker|
teacher_ids = poll.course.teachers.pluck(:user_id) teacher_ids = teachers.pluck(:user_id)
unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids) unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids)
poll.course.teachers.find_each do |teacher| teacher_ids.find_each do |user_id|
worker.add same_attrs.merge(user_id: teacher.user_id) worker.add same_attrs.merge(user_id: user_id)
end end
end end
receiver_ids.each do |user_id| students.pluck(:user_id).each do |user_id|
worker.add same_attrs.merge(user_id: user_id) worker.add same_attrs.merge(user_id: user_id)
end end
end end

@ -0,0 +1,10 @@
class UpdateMyshixunWorkStatusJob < ApplicationJob
queue_as :default
def perform(myshixun_id)
myshixun = Myshixun.find_by(id: myshixun_id)
return if myshixun.blank?
HomeworksService.new.update_myshixun_work_status myshixun
end
end

@ -38,7 +38,7 @@ class Challenge < ApplicationRecord
## 选择题总分 ## 选择题总分
def choose_score def choose_score
self.challenge_chooses.sum(:score) self.challenge_chooses.pluck(:score).sum
end end
# 关卡总分 # 关卡总分
@ -51,9 +51,8 @@ class Challenge < ApplicationRecord
end end
# 开启挑战 # 开启挑战
def open_game(user_id) def open_game user_id, shixun
game = self.games.select([:status, :identifier]).where(user_id: user_id).first game = self.games.first
shixun = self.shixun
if game.present? if game.present?
shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : ""
else else
@ -61,18 +60,31 @@ class Challenge < ApplicationRecord
end end
end end
# # 开启挑战
# def open_game(user_id, shixun)
#
#
# game = self.games.select([:status, :identifier]).where(user_id: user_id).first
# game = self.games.select{|game| game.user_id == user_id}
# if game.present?
# shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : ""
# else
# "/api/shixuns/#{shixun.identifier}/shixun_exec"
# end
# end
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成 ## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
def user_tpi_status user_id def user_tpi_status user_id
# todo: 以前没加索引导致相同关卡,同一用户有多个games # todo: 以前没加索引导致相同关卡,同一用户有多个games
game = self.games.where(user_id: user_id).last game = games.last
status =
if game.blank? if game.blank?
self.position == 1 ? 1 : 0 self.position == 1 ? 1 : 0
elsif game.status == 2 elsif game.status == 2
2 2
else else
1 1
end end
end end
## 选择题答案 ## 选择题答案

@ -33,10 +33,16 @@ class Discuss < ApplicationRecord
"/tasks/#{game&.identifier}" "/tasks/#{game&.identifier}"
end end
def contents(shixun, user) # def contents(shixun, user)
return content unless hidden? # return content unless hidden?
#
shixun.has_manager?(user) ? content : '违规评论已被屏蔽!' # shixun.has_manager?(user) ? content : ''
# end
def child_discuss(user)
user.admin? ?
Discuss.where(parent_id: self.id).includes(:user).reorder(created_at: :asc) :
Discuss.where(parent_id: self.id, :hidden => false).includes(:user).reorder(created_at: :asc)
end end
private private

@ -3,11 +3,11 @@ class Exercise < ApplicationRecord
belongs_to :exercise_bank, optional: true belongs_to :exercise_bank, optional: true
belongs_to :user belongs_to :user
has_many :exercise_users,:dependent => :destroy has_many :exercise_users, :dependent => :delete_all
has_many :exercise_questions,:dependent => :destroy has_many :exercise_questions, :dependent => :delete_all
has_many :exercise_group_settings,:dependent => :destroy has_many :exercise_group_settings, :dependent => :delete_all
has_many :tidings, as: :container has_many :tidings, as: :container
has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :destroy has_many :course_acts, class_name: 'CourseActivity', as: :course_act, :dependent => :delete_all
scope :is_exercise_published, -> { where("exercise_status > ? ",1)} scope :is_exercise_published, -> { where("exercise_status > ? ",1)}
scope :unified_setting, -> { where("unified_setting = ?",true) } scope :unified_setting, -> { where("unified_setting = ?",true) }

@ -3,7 +3,7 @@ class ExerciseAnswer < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :exercise_question belongs_to :exercise_question
belongs_to :exercise_choice, optional: true belongs_to :exercise_choice, optional: true
has_many :exercise_answer_comments, :dependent => :destroy has_many :exercise_answer_comments, :dependent => :delete_all
scope :search_exercise_answer, lambda { |name,key| where("#{name} = ?",key)} scope :search_exercise_answer, lambda { |name,key| where("#{name} = ?",key)}
scope :search_answer_users, lambda {|name,ids| where("#{name}":ids)} scope :search_answer_users, lambda {|name,ids| where("#{name}":ids)}

@ -1,9 +1,10 @@
class ExerciseChoice < ApplicationRecord class ExerciseChoice < ApplicationRecord
belongs_to :exercise_question belongs_to :exercise_question
has_many :exercise_answers, :dependent => :destroy has_many :exercise_answers, :dependent => :delete_all
has_many :exercise_standard_answers, :dependent => :destroy has_many :exercise_standard_answers, :dependent => :delete_all
scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
end end

@ -4,19 +4,18 @@ class ExerciseQuestion < ApplicationRecord
belongs_to :exercise belongs_to :exercise
belongs_to :shixun, optional: true belongs_to :shixun, optional: true
has_many :exercise_choices, :dependent => :destroy has_many :exercise_choices, :dependent => :delete_all
has_many :exercise_answers, :dependent => :destroy has_many :exercise_answers
has_many :exercise_shixun_challenges,:dependent => :destroy has_many :exercise_shixun_challenges, :dependent => :delete_all
has_many :exercise_shixun_answers, :dependent => :destroy has_many :exercise_shixun_answers
has_many :exercise_answer_comments, :dependent => :destroy has_many :exercise_answer_comments
has_many :exercise_standard_answers, :dependent => :destroy has_many :exercise_standard_answers
scope :insert_question_ex, lambda {|k| where("question_number > ?",k)} scope :insert_question_ex, lambda {|k| where("question_number > ?",k)}
scope :find_by_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :find_by_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题
# scope :next_exercise, lambda {|k| where("question_number > ?",k).first}
# scope :last_exercise, lambda {|k| where("question_number < ?",k).last}
def question_type_name def question_type_name
case self.question_type case self.question_type

@ -2,7 +2,7 @@ class ExerciseShixunAnswer < ApplicationRecord
belongs_to :exercise_question belongs_to :exercise_question
belongs_to :user belongs_to :user
belongs_to :exercise_shixun_challenge belongs_to :exercise_shixun_challenge
has_many :exercise_answer_comments, :dependent => :destroy has_many :exercise_answer_comments, :dependent => :delete_all
# status 0: 未通过, 1通过 # status 0: 未通过, 1通过
# attr_accessible :answer_text, :score, :status # attr_accessible :answer_text, :score, :status
scope :search_shixun_answers, lambda {|name,ids| where("#{name}":ids)} scope :search_shixun_answers, lambda {|name,ids| where("#{name}":ids)}

@ -63,7 +63,7 @@ class GraduationWork < ApplicationRecord
#用户是否有查看分数的权限 #用户是否有查看分数的权限
def check_score_power? current_user, course_identity def check_score_power? current_user, course_identity
self.work_score.present? || course_identity < Course::STUDENT || self.user_id = current_user.id self.work_score.present? && (course_identity < Course::STUDENT || self.user_id = current_user.id || graduation_task.open_score)
end end
# 作品是否能够分配指导老师 # 作品是否能够分配指导老师

@ -70,7 +70,7 @@ class HomeworkCommon < ApplicationRecord
if self.course_second_category.present? if self.course_second_category.present?
{category_id: self.course_second_category.try(:id), category_name: self.course_second_category.try(:name)} {category_id: self.course_second_category.try(:id), category_name: self.course_second_category.try(:name)}
else else
{category_id: course.shixun_course_modules.first.try(:id), category_name: course.shixun_course_modules.first.try(:module_name)} {category_id: course.shixun_course_modules.take.try(:id), category_name: course.shixun_course_modules.take.try(:module_name)}
end end
end end
end end
@ -78,8 +78,7 @@ class HomeworkCommon < ApplicationRecord
# 根据是否统一发布获取作业的作品列表 # 根据是否统一发布获取作业的作品列表
def all_works def all_works
student_works = self.unified_setting ? self.student_works : student_works = self.unified_setting ? self.student_works :
self.student_works.joins("join course_members on student_works.user_id=course_members.user_id"). self.student_works.joins("join course_members on student_works.user_id=course_members.user_id").where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)})
where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)})
end end
# 分班权限的老师可见的作品列表 # 分班权限的老师可见的作品列表
@ -90,7 +89,7 @@ class HomeworkCommon < ApplicationRecord
# 有分班权限的统计管理的分班且已发布的学生情况 # 有分班权限的统计管理的分班且已发布的学生情况
if member.present? && teacher_course_groups.size > 0 if member.present? && teacher_course_groups.size > 0
group_ids = teacher_course_groups.pluck(:course_group_id) group_ids = teacher_course_groups.pluck(:course_group_id)
all_student_works = all_student_works.joins("join course_members course_members on student_works.user_id=course_members.user_id"). all_student_works = all_student_works.joins("join course_members on student_works.user_id=course_members.user_id").
where(course_members: {course_group_id: group_ids}) where(course_members: {course_group_id: group_ids})
end end
all_student_works all_student_works
@ -170,12 +169,8 @@ class HomeworkCommon < ApplicationRecord
#删除时更新题库中的引用数 #删除时更新题库中的引用数
def update_homework_bank_quotes def update_homework_bank_quotes
old_banks = self.homework_bank old_bank = self.homework_bank
unless old_banks.blank? old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) if old_bank.present?
old_banks.each do |bank|
bank.update_attributes(quotes: (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0, homework_common_id: nil)
end
end
end end
# 查重是否有新结果 # 查重是否有新结果

@ -53,14 +53,12 @@ class Myshixun < ApplicationRecord
end end
# 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录) # 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录)
# status:0 可以测评的,正在测评 # status:0 可以测评的; 1 正在测评的; 2评测通过的 3未开启
# 如果都完成,则当前任务为最后一个任务 # 如果都完成,则当前任务为最后一个任务
def current_task def current_task games
games = self.games
current_game = games.select{|game| game.status == 1 || game.status == 0}.first current_game = games.select{|game| game.status == 1 || game.status == 0}.first
if current_game.blank? if current_game.blank?
current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} current_game = games.last
and g.challenge_id = c.id and g.status = 2 order by c.position desc").first
end end
current_game current_game
end end
@ -74,12 +72,12 @@ class Myshixun < ApplicationRecord
# 个人实训得分 # 个人实训得分
def total_score def total_score
self.games.where("status = 2 and final_score > 0").sum(:final_score).to_i self.games.select{|game| game.status == 2 && game.final_score > 0}.pluck(:final_score).sum.to_i
end end
# 个人通关数 # 个人通关数
def passed_count def passed_count
self.games.where(status: 2).count self.games.select{|game| game.status == 2}.size
end end
# 通关时间 # 通关时间
@ -89,12 +87,12 @@ class Myshixun < ApplicationRecord
# 耗时 # 耗时
def total_spend_time def total_spend_time
game_spend_time self.games.where(status: 2).sum(:cost_time).to_i game_spend_time total_cost_time
end end
# 通关总耗时 # 通关总耗时
def total_cost_time def total_cost_time
self.games.where(status: 2).sum(:cost_time).to_i self.games.select{|game| game.status == 2}.map(&:cost_time).sum.to_i
end end
end end

@ -4,13 +4,13 @@ class Poll < ApplicationRecord
belongs_to :exercise_bank, optional: true belongs_to :exercise_bank, optional: true
# belongs_to :exercise_bank # belongs_to :exercise_bank
has_many :poll_questions,dependent: :destroy has_many :poll_questions,dependent: :delete_all
has_many :poll_users, :dependent => :destroy has_many :poll_users, :dependent => :delete_all
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过 has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
has_many :poll_group_settings, :dependent => :destroy has_many :poll_group_settings, :dependent => :delete_all
has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :destroy has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :delete_all
has_many :tidings, as: :container, dependent: :destroy has_many :tidings, as: :container, dependent: :delete_all
scope :publish_or_not, -> { where("polls_status > ? ",1)} scope :publish_or_not, -> { where("polls_status > ? ",1)}
scope :only_public, -> {where("is_public = ?",true)} scope :only_public, -> {where("is_public = ?",true)}
@ -137,16 +137,17 @@ class Poll < ApplicationRecord
#判断当前用户的答题状态 #判断当前用户的答题状态
def check_user_votes_status(user) def check_user_votes_status(user)
poll_answer_user = poll_users.find_by(user_id: user.id) poll_answer_user = poll_users.find_by(user_id: user.id)
user_poll_status = get_poll_status(user.id) # user_poll_status = get_poll_status(user.id)
user_status = 2 user_status = 2
if poll_answer_user.present? && (poll_answer_user.start_at.present? || poll_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 if poll_answer_user.present? && (poll_answer_user.start_at.present? || poll_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = poll_answer_user.commit_status user_status = poll_answer_user.commit_status
end end
#
if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 # if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3
user_status = 4 # # user_status = 4
end # user_status = 2 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示
# end
user_status user_status
end end

@ -3,7 +3,7 @@ class PollAnswer < ApplicationRecord
# include Redmine::SafeAttributes # include Redmine::SafeAttributes
belongs_to :poll_question belongs_to :poll_question
has_many :poll_votes, :dependent => :destroy has_many :poll_votes, :dependent => :delete_all
scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题 scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题
scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题

@ -1,9 +1,9 @@
class PollQuestion < ApplicationRecord class PollQuestion < ApplicationRecord
belongs_to :poll belongs_to :poll
has_many :poll_answers, :dependent => :destroy has_many :poll_answers, :dependent => :delete_all
attr_accessor :question_answers, :question_other_anser attr_accessor :question_answers, :question_other_anser
has_many :poll_votes, :dependent => :destroy has_many :poll_votes
scope :ques_count, lambda {|k| where("question_type = ?",k)} scope :ques_count, lambda {|k| where("question_type = ?",k)}
scope :ques_necessary, -> {where("is_necessary = ?",1)} scope :ques_necessary, -> {where("is_necessary = ?",1)}

@ -39,24 +39,34 @@ class StudentWork < ApplicationRecord
# 助教评分次数 # 助教评分次数
def ta_comment_count def ta_comment_count
self.student_works_scores.where(reviewer_role: 2).group_by(&:user_id).count self.student_works_scores.select{|score| score.reviewer_role == 2}.group_by(&:user_id).count
end end
# 匿评次数 # 匿评次数
def student_comment_num def student_comment_num
homework_common.homework_detail_manual.comment_status > 2 ? self.student_works_scores.where(reviewer_role: 3).group_by(&:user_id).count : 0 homework_common.homework_detail_manual.comment_status > 2 ? self.student_works_scores.select{|score| score.reviewer_role == 3}.group_by(&:user_id).count : 0
end end
# 匿评申诉总条数 # 匿评申诉总条数
def appeal_all_count def appeal_all_count
homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores.where("reviewer_role = 3 and appeal_status != 0"). homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores.
group_by(&:user_id).count : 0 select{|score| score.reviewer_role == 3 && score.appeal_status != 0}.group_by(&:user_id).count : 0
end end
# 匿评申诉待处理条数 # 匿评申诉待处理条数
def appeal_deal_count def appeal_deal_count
homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores.where("reviewer_role = 3 and appeal_status = 1"). homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores.
group_by(&:user_id).count : 0 select{|score| score.reviewer_role == 3 && score.appeal_status == 1}.group_by(&:user_id).count : 0
end
# 当前用户该作品的匿评申诉总条数
def my_appeal_all_count user_id
student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status != 0 && score.user_id == user_id}.size
end
# 当前用户该作品的匿评申诉总条数
def my_appeal_deal_count user_id
student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status == 1 && score.user_id == user_id}.size
end end
# 分组名 # 分组名

@ -48,42 +48,41 @@ class ExerciseUserPdfService
def load_data def load_data
@exercise_questions = exercise.exercise_questions @exercise_questions = exercise.exercise_questions
@exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_count = @exercise_questions.size # 全部的题目数
@exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum
#单选题的数量及分数 #单选题的数量及分数
exercise_single_ques = @exercise_questions.find_by_custom("question_type",0) exercise_single_ques = @exercise_questions.find_by_custom("question_type",0)
@exercise_single_ques_count = exercise_single_ques.all.count @exercise_single_ques_count = exercise_single_ques.size
@exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum @exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum
#多选题的数量及分数 #多选题的数量及分数
exercise_double_ques = @exercise_questions.find_by_custom("question_type",1) exercise_double_ques = @exercise_questions.find_by_custom("question_type",1)
@exercise_double_ques_count = exercise_double_ques.all.count @exercise_double_ques_count = exercise_double_ques.size
@exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum @exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum
# 判断题数量及分数 # 判断题数量及分数
exercise_ques_judge = @exercise_questions.find_by_custom("question_type",2) exercise_ques_judge = @exercise_questions.find_by_custom("question_type",2)
@exercise_ques_judge_count = exercise_ques_judge.all.count @exercise_ques_judge_count = exercise_ques_judge.size
@exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum @exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum
#填空题数量及分数 #填空题数量及分数
exercise_ques_null = @exercise_questions.find_by_custom("question_type",3) exercise_ques_null = @exercise_questions.find_by_custom("question_type",3)
@exercise_ques_null_count = exercise_ques_null.all.count @exercise_ques_null_count = exercise_ques_null.size
@exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum @exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum
#简答题数量及分数 #简答题数量及分数
exercise_ques_main = @exercise_questions.find_by_custom("question_type",4) exercise_ques_main = @exercise_questions.find_by_custom("question_type",4)
@exercise_ques_main_count = exercise_ques_main.all.count @exercise_ques_main_count = exercise_ques_main.size
@exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum @exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum
#实训题数量及分数 #实训题数量及分数
exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5)
@exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_count = exercise_ques_shixun.size
@exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum
challenge_ids = @exercise_questions.joins(:exercise_shixun_challenges).pluck("exercise_shixun_challenges.challenge_id") @exercise_questions = @exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers)
get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id)
@games = @exercise_user.user.games.ch_games(challenge_ids)
end end
end end

@ -33,7 +33,12 @@ class GitService
res = https.request(req) res = https.request(req)
body = res.body body = res.body
logger.info("--uri_exec: .....res is #{body}") logger.info("--uri_exec: .....res is #{body}")
content = JSON.parse(body) content = JSON.parse(body)
if content["code"] != 0
raise("版本库异常")
logger.error("repository error: #{content['msg']}")
end
#raise content["msg"] if content["code"] != 0 #raise content["msg"] if content["code"] != 0
content["data"] content["data"]

@ -8,39 +8,24 @@ class ExercisePublishTask
exercises = Exercise.includes(:exercise_users).where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) exercises = Exercise.includes(:exercise_users).where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
exercises&.each do |exercise| exercises&.each do |exercise|
exercise.update_column('exercise_status', 2) exercise.update_column('exercise_status', 2)
course = exercise.course
tid_str = ""
course.teachers.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if exercise.unified_setting if exercise.unified_setting
course.students.find_each do |student| ExercisePublishNotifyJob.perform_later(exercise.id, nil)
else
course = exercise.course
teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id))
tid_str = ""
teachers.find_each do |member|
tid_str += "," if tid_str != "" tid_str += "," if tid_str != ""
tid_str += "(#{student.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" tid_str += "(#{member.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
end if tid_str != ""
if tid_str != "" tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str ActiveRecord::Base.connection.execute tid_sql
ActiveRecord::Base.connection.execute tid_sql
end
if exercise.exercise_users.size == 0
str = ""
course.students.find_each do |student|
str += "," if str != ""
str += "(#{student.user_id}, #{exercise.id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into exercise_users (user_id, exercise_id, commit_status, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end end
end end
if exercise.course_acts.size == 0 exercise.course_acts << CourseActivity.new(user_id: exercise.user_id, course_id: exercise.course_id) if !exercise.course_acts.exists?
exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id)
end
end end
# 分组设置发布时间的测验 # 分组设置发布时间的测验
@ -48,18 +33,8 @@ class ExercisePublishTask
exercise_group_settings&.each do |exercise_group| exercise_group_settings&.each do |exercise_group|
exercise = exercise_group.exercise exercise = exercise_group.exercise
if exercise.present? if exercise.present?
course = exercise.course
exercise.update_attributes(:exercise_status => 2) if exercise.exercise_status == 1 exercise.update_attributes(:exercise_status => 2) if exercise.exercise_status == 1
tid_str = "" ExercisePublishNotifyJob.perform_later(exercise.id, [exercise_group.course_group_id])
members = course.students.where(:course_group_id => exercise_group.course_group_id)
members.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id},#{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql
end
end end
end end
Rails.logger.info("log--------------------------------exercise_publish end") Rails.logger.info("log--------------------------------exercise_publish end")

@ -156,7 +156,7 @@ p{
position: absolute; position: absolute;
display: inline-block; display: inline-block;
bottom: 6px; bottom: 6px;
/*left: 1px;*/ left: 1px;
} }
.line-line { .line-line {
@ -231,7 +231,7 @@ p{
position: absolute; position: absolute;
display: inline-block; display: inline-block;
bottom: 9px; bottom: 9px;
left: 1px; left: 2px;
} }
.circle-right:after{ .circle-right:after{
color:#fff; color:#fff;

@ -112,6 +112,7 @@
<div class="mbt10"> <div class="mbt10">
<% @exercise_questions.each do |q| %> <% @exercise_questions.each do |q| %>
<% q_type = q.question_type %> <% q_type = q.question_type %>
<% games =( q_type == 5 ? @ex_user_user.games.ch_games(q.exercise_shixun_challenges.pluck(:challenge_id)) : nil) %>
<% user_answer = (q_type == 5 ? q.exercise_shixun_answers.where(user_id: @ex_user_user.id) : q.exercise_answers.where(user_id: @ex_user_user.id)) %> <% user_answer = (q_type == 5 ? q.exercise_shixun_answers.where(user_id: @ex_user_user.id) : q.exercise_answers.where(user_id: @ex_user_user.id)) %>
<% this_ques_status = @ex_obj_array.detect{|f| f[:q_id] == q.id} %> <% this_ques_status = @ex_obj_array.detect{|f| f[:q_id] == q.id} %>
<% main_ques_status = @ex_sub_array.detect{|f| f[:q_id] == q.id} %> <% main_ques_status = @ex_sub_array.detect{|f| f[:q_id] == q.id} %>
@ -247,8 +248,8 @@
<th width="13%">得分/满分</th> <th width="13%">得分/满分</th>
</thead> </thead>
<tbody> <tbody>
<% if @games.size > 0 %> <% if games.present? %>
<% @games.each_with_index do |game, index| %> <% games&.each_with_index do |game, index| %>
<% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %>
<% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id: game_score&.first&.id,user_id: @ex_user_user.id) %> <% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id: game_score&.first&.id,user_id: @ex_user_user.id) %>
<tr> <tr>
@ -286,7 +287,7 @@
<p class="text-gray mbt10"> <p class="text-gray mbt10">
<span class="fl font-bd">实训详情</span> <span class="fl font-bd">实训详情</span>
</p> </p>
<% @games.each_with_index do |game, index| %> <% games&.each_with_index do |game, index| %>
<div class="mbt10"> <div class="mbt10">
<p class="clearfix"> <p class="clearfix">
<span class="fl mt3"><span class="font-bd mr15">第<%= index+1 %>关</span><%= game.challenge.subject %></span> <span class="fl mt3"><span class="font-bd mr15">第<%= index+1 %>关</span><%= game.challenge.subject %></span>

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

@ -2,7 +2,7 @@ json.author do
json.partial! 'users/user', user: discuss.user json.partial! 'users/user', user: discuss.user
end end
json.id discuss.id json.id discuss.id
json.content discuss.contents(container, current_user) json.content discuss.content
json.time time_from_now(discuss.created_at) json.time time_from_now(discuss.created_at)
json.position discuss.position json.position discuss.position
json.shixun_id discuss.dis_id json.shixun_id discuss.dis_id

@ -2,8 +2,7 @@ json.disscuss_count @disscuss_count
json.all @current_user.admin? json.all @current_user.admin?
json.comments @discusses do |discuss| json.comments @discusses do |discuss|
json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user } json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user }
child_discuss = Discuss.children(discuss.id) json.children discuss.child_discuss(current_user) do |c_d|
json.children child_discuss do |c_d|
json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user } json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user }
end end
end end

@ -6,10 +6,11 @@ json.question_type question.question_type
json.question_score question.question_score.round(1).to_s json.question_score question.question_score.round(1).to_s
if question.question_type <= 2 #当为选择题或判断题时,只显示选项的位置 if question.question_type <= 2 #当为选择题或判断题时,只显示选项的位置
standard_answers_array = question.get_standard_answer_ids standard_answers_array = question.get_standard_answer_ids
exercise_choices = choices.order("choice_position ASC")
ex_choice_random_boolean = (exercise_type.present? && exercise_type == 3 && (question.exercise.choice_random)) ? true : false #问题的选项随机打乱 ex_choice_random_boolean = (exercise_type.present? && exercise_type == 3 && (question.exercise.choice_random)) ? true : false #问题的选项随机打乱
if ex_choice_random_boolean if ex_choice_random_boolean
exercise_choices = exercise_choices.order("RAND()") exercise_choices = choices.order("RAND()")
else
exercise_choices = choices.order("choice_position ASC")
end end
json.question_choices do json.question_choices do
json.array! exercise_choices.each_with_index.to_a do |a,index| json.array! exercise_choices.each_with_index.to_a do |a,index|

@ -47,14 +47,13 @@ end
json.exercise_questions do json.exercise_questions do
json.array! exercise_questions do |q| json.array! exercise_questions do |q|
user_ques_answers = user_question_answers(q,ex_answerer.id,student_status,is_teacher_or,exercise_status,q.question_type,ex_type) user_ques_answers = user_question_answers(q,ex_answerer.id,student_status,is_teacher_or,exercise_status,q.question_type,ex_type)
user_ques_comments = user_ques_answers[:question_comment] user_ques_comments = user_ques_answers[:question_comment]
if all_question_status.size > 0 if all_question_status.size > 0
this_ques_status = all_question_status.detect {|f| f[:q_id] == q.id} this_ques_status = all_question_status.detect {|f| f[:q_id] == q.id}
json.answer_status this_ques_status[:stand_status] json.answer_status this_ques_status[:stand_status]
end end
json.user_score user_ques_answers[:user_score].to_s json.user_score user_ques_answers[:user_score]
json.partial! "exercise_questions/exercise_questions", json.partial! "exercise_questions/exercise_questions",
question: q, question: q,
ex_answerer: ex_answerer, ex_answerer: ex_answerer,

@ -40,8 +40,8 @@ json.exercise_questions do
question_info = get_exercise_question_info(question,@exercise,@exercise_user_current,@ex_answerer.id) question_info = get_exercise_question_info(question,@exercise,@exercise_user_current,@ex_answerer.id)
# json.q_position q[:ques_number] #问题的序号,当问题为随机时,重新更新后的问题序号 # json.q_position q[:ques_number] #问题的序号,当问题为随机时,重新更新后的问题序号
if @t_user_exercise_status == 3 if @t_user_exercise_status == 3
this_answer_status = "0.0" this_answer_status = 0
user_score = "0.0" user_score = nil
if all_question_status.size > 0 if all_question_status.size > 0
this_ques_status = all_question_status.detect {|f| f[:q_id] == question.id} this_ques_status = all_question_status.detect {|f| f[:q_id] == question.id}
this_answer_status = this_ques_status[:stand_status] this_answer_status = this_ques_status[:stand_status]

@ -1,2 +1,10 @@
json.status @status json.test_sets @qurey_test_sets do |test_set|
json.message @message json.is_public test_set.is_public
json.result test_set.try(:result)
if test_set.is_public || @allowed_hidden_testset
json.input test_set.input
json.output test_set.output
json.actual_output evaluate_actual_output(test_set)
end
json.compile_success test_set.try(:compile_success)
end

@ -59,6 +59,7 @@ if @task.published? || @user_course_identity < Course::STUDENT
json.late_penalty work.late_penalty if @task.allow_late json.late_penalty work.late_penalty if @task.allow_late
json.final_score work_final_score work, @current_user, @user_course_identity json.final_score work_final_score work, @current_user, @user_course_identity
json.assign work.assign_power?(@user_course_identity) json.assign work.assign_power?(@user_course_identity)
json.view_work @view_work || @current_user.id == work.user_id
end end
end end
end end

@ -10,5 +10,5 @@ json.homework_name homework.name
json.homework_id homework.id json.homework_id homework.id
json.homework_type homework.homework_type json.homework_type homework.homework_type
if homework.homework_type == "practice" if homework.homework_type == "practice"
json.shixun_identifier homework.shixuns.first.try(:identifier) json.shixun_identifier homework.shixuns.take.try(:identifier)
end end

@ -2,10 +2,6 @@ json.course_identity @user_course_identity
json.homework_type @homework_type json.homework_type @homework_type
json.course_public @course.is_public == 1 json.course_public @course.is_public == 1
json.is_end @course.is_end json.is_end @course.is_end
json.all_count @all_count
json.published_count @published_count
json.unpublished_count @all_count - @published_count
json.task_count @task_count
json.main_category_id @main_category.try(:id) json.main_category_id @main_category.try(:id)
json.main_category_name @main_category.try(:module_name) json.main_category_name @main_category.try(:module_name)
json.category_id @category.try(:id) json.category_id @category.try(:id)
@ -46,3 +42,8 @@ json.homeworks @homework_commons.each do |homework|
end end
end end
json.all_count @all_count
json.published_count @published_count
json.unpublished_count @all_count - @published_count
json.task_count @task_count

@ -33,19 +33,19 @@ elsif @user_course_identity == Course::STUDENT
json.late_penalty @work.late_penalty if @homework.allow_late json.late_penalty @work.late_penalty if @homework.allow_late
json.cost_time @work.myshixun.try(:total_cost_time) json.cost_time @work.myshixun.try(:total_cost_time)
json.work_score work_score_format(@work.work_score, true, @homework.score_open) json.work_score work_score_format(@work.work_score, true, @score_open)
json.final_score work_score_format(@work.final_score, true, @homework.score_open) json.final_score work_score_format(@work.final_score, true, @score_open)
json.efficiency work_score_format(@work.efficiency, true, @homework.score_open) json.efficiency work_score_format(@work.efficiency, true, @score_open)
json.eff_score work_score_format(@work.eff_score, true, @homework.score_open) json.eff_score work_score_format(@work.eff_score, true, @score_open)
json.complete_count @work.myshixun.try(:passed_count) json.complete_count @work.myshixun.try(:passed_count)
else else
json.(@work, :id, :work_status, :update_time, :ultimate_score) json.(@work, :id, :work_status, :update_time, :ultimate_score)
json.work_score work_score_format(@work.work_score, true, @homework.score_open) json.work_score work_score_format(@work.work_score, true, @score_open)
json.final_score work_score_format(@work.final_score, true, @homework.score_open) json.final_score work_score_format(@work.final_score, true, @score_open)
json.teacher_score work_score_format(@work.teacher_score, true, @homework.score_open) json.teacher_score work_score_format(@work.teacher_score, true, @score_open)
json.student_score work_score_format(@work.student_score, true, @homework.score_open) json.student_score work_score_format(@work.student_score, true, @score_open)
json.teaching_asistant_score work_score_format(@work.teaching_asistant_score, true, @homework.score_open) json.teaching_asistant_score work_score_format(@work.teaching_asistant_score, true, @score_open)
json.ta_comment_count @work.ta_comment_count json.ta_comment_count @work.ta_comment_count
@ -84,10 +84,10 @@ if @homework.homework_type == "practice"
json.(work, :id, :work_status, :update_time, :ultimate_score) json.(work, :id, :work_status, :update_time, :ultimate_score)
json.late_penalty work.late_penalty if @homework.allow_late json.late_penalty work.late_penalty if @homework.allow_late
json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open)
json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) json.final_score work_score_format(work.final_score, @current_user == work.user, @score_open)
json.efficiency work_score_format(work.efficiency, @current_user == work.user, @homework.score_open) json.efficiency work_score_format(work.efficiency, @current_user == work.user, @score_open)
json.eff_score work_score_format(work.eff_score, @current_user == work.user, @homework.score_open) json.eff_score work_score_format(work.eff_score, @current_user == work.user, @score_open)
json.cost_time work.myshixun.try(:total_cost_time) json.cost_time work.myshixun.try(:total_cost_time)
json.complete_count work.myshixun.try(:passed_count) json.complete_count work.myshixun.try(:passed_count)
@ -101,22 +101,27 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.anonymous_appeal @homework.anonymous_appeal json.anonymous_appeal @homework.anonymous_appeal
json.student_works @student_works.each do |work| json.student_works @student_works.each do |work|
if @is_evaluation if @is_evaluation
json.(work, :id, :work_status, :update_time) json.(work, :id, :work_status, :update_time)
json.student_score work_score_format(anon_comments(@current_user, work.id).last.try(:score), false, true) json.student_score work_score_format(anon_comments(@current_user, work.id).last.try(:score), false, true)
# json.student_comment_count anon_comments(@current_user, work.id).count # json.student_comment_count anon_comments(@current_user, work.id).count
# 申诉条数
if @homework.anonymous_appeal
json.appeal_all_count work.my_appeal_all_count @current_user.id
json.appeal_deal_count work.my_appeal_deal_count @current_user.id
end
else else
json.(work, :id, :work_status, :update_time, :work_score, :final_score, :teacher_score, :student_score, json.(work, :id, :work_status, :update_time, :work_score, :final_score, :teacher_score, :student_score,
:teaching_asistant_score, :ultimate_score) :teaching_asistant_score, :ultimate_score)
json.late_penalty work.late_penalty if @homework.allow_late json.late_penalty work.late_penalty if @homework.allow_late
json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open)
json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) json.final_score work_score_format(work.final_score, @current_user == work.user, @score_open)
json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @homework.score_open) json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @score_open)
json.student_score work_score_format(work.student_score, @current_user == work.user, @homework.score_open) json.student_score work_score_format(work.student_score, @current_user == work.user, @score_open)
json.teaching_asistant_score work_score_format(work.teaching_asistant_score, @current_user == work.user, @homework.score_open) json.teaching_asistant_score work_score_format(work.teaching_asistant_score, @current_user == work.user, @score_open)
# 助教评分次数 # 助教评分次数
json.ta_comment_count work.ta_comment_count json.ta_comment_count work.ta_comment_count
@ -135,13 +140,13 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
end end
json.work_group work.work_group_name json.work_group work.work_group_name
end end
end
# 申诉条数 # 申诉条数
if @homework.anonymous_appeal if @homework.anonymous_appeal
json.appeal_all_count work.appeal_all_count json.appeal_all_count work.appeal_all_count
json.appeal_deal_count work.appeal_deal_count json.appeal_deal_count work.appeal_deal_count
json.appeal_penalty work.appeal_penalty json.appeal_penalty work.appeal_penalty
end
end end
json.user_login @is_evaluation ? "--" : work.user.try(:login) json.user_login @is_evaluation ? "--" : work.user.try(:login)

@ -1,16 +1,14 @@
wb = xlsx_package.workbook wb = xlsx_package.workbook
wb.use_autowidth = false # wb.use_autowidth = false
wb.styles do |s| wb.styles do |s|
sz_all = s.add_style :sz => 10,:border => { :style => :thin, :color =>"000000"},:alignment => {:horizontal => :left} sz_all = s.add_style :sz => 10,:border => { :style => :thin, :color =>"000000"},:alignment => {wrap_text: true,:horizontal => :left}
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :left} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :left}
wb.add_worksheet(:name => "统计结果") do |sheet| wb.add_worksheet(:name => "统计结果") do |sheet|
sheet.sheet_view.show_grid_lines = false sheet.sheet_view.show_grid_lines = false
poll_users_info = %w(序号) poll_users_info = %w(序号)
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?}
poll_ques_ids = poll_questions.pluck(:id).sort #问题的全部id
poll_un_anony = @poll.un_anonymous poll_un_anony = @poll.un_anonymous
if poll_un_anony #是否匿名默认为false if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号) user_info = %w(登陆名 真实姓名 邮箱 学号)
@ -32,25 +30,25 @@ wb.styles do |s|
sheet_answer_row.push(answer_users_count) sheet_answer_row.push(answer_users_count)
sheet_answer_percent.push(answer_percent.to_s) sheet_answer_percent.push(answer_percent.to_s)
end end
sheet.add_row sheet_row, :style => blue_cell sheet.add_row sheet_row, :height =>15,:style => blue_cell
sheet.add_row sheet_answer_row, :style => sz_all sheet.add_row sheet_answer_row, :height =>15, :style => sz_all
sheet.add_row sheet_answer_percent, :style => sz_all sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all
sheet.add_row sheet_answer_useful, :style => sz_all sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all
#合并单元格但无法填充style #合并单元格但无法填充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.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.rows[sheet.rows.last.row_index].style = sz_all
sheet.add_row [] sheet.add_row []
else #主观题答案 else #主观题答案
main_show_row = ["第#{q.question_number}题",q.question_title] main_show_row = ["第#{q.question_number}题",q.question_title]
sheet.add_row main_show_row, :style => blue_cell sheet.add_row main_show_row,:height =>15, :style => blue_cell
q.poll_votes.each do |v| #主观题的答案 q.poll_votes.each do |v| #主观题的答案
sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"], :style => sz_all sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all
end end
sheet.add_row [], :style => sz_all sheet.add_row [], :style => sz_all
end end
end #each_with_index end #each_with_index
sheet.add_row poll_users_info, :style => blue_cell sheet.add_row poll_users_info, :height =>15, :style => blue_cell
@poll.poll_users.each_with_index do |u,index| @poll.poll_users.each_with_index do |u,index|
u_user = u.user u_user = u.user
user_answer_array = [] user_answer_array = []
@ -88,7 +86,7 @@ wb.styles do |s|
user_cell += [user_login,user_name, u_user.mail, user_student_id] user_cell += [user_login,user_name, u_user.mail, user_student_id]
end end
all_user_cell = user_cell + user_answer_array all_user_cell = user_cell + user_answer_array
sheet.add_row all_user_cell, :style => sz_all sheet.add_row all_user_cell, :height =>15,:style => sz_all
end end
sheet.column_widths *([25]*sheet.column_info.count) sheet.column_widths *([25]*sheet.column_info.count)
sheet.column_info.first.width = 10 sheet.column_info.first.width = 10

@ -1,7 +1,6 @@
json.course do json.course do
json.partial! "polls/course_name",locals:{course:@course} json.partial! "polls/course_name",locals:{course:@course}
end end
json.poll_types do json.poll_types do
if @poll_current_user_status == 0 if @poll_current_user_status == 0
json.published_count @poll_publish_count json.published_count @poll_publish_count

@ -1,7 +1,8 @@
#json.partial! "users/users_list", users: @users #json.partial! "users/users_list", users: @users
json.user_count @users_count
json.array! @users do |user| json.array! @users do |user|
json.user_id user.id json.user_id user.id
json.identify user.identity json.identify user.identity
json.nickname user.nickname json.nickname user.real_name
json.school_name user.school_name json.school_name user.school_name
end end

@ -1,4 +1,3 @@
json.status 1 json.status 1
json.message "发送成功" json.message "发送成功"
json.url course_homework_commons_path(@course.id, type: 4) json.course_id @course.id
# json.url "#{Rails::configuration.educoder['old_edu_host']}/homework_common?course=#{@course.id}&homework_type=4"

@ -117,6 +117,7 @@ Rails.application.routes.draw do
get :close_webssh get :close_webssh
get :get_answer_info get :get_answer_info
get :unlock_answer get :unlock_answer
get :check_test_sets
end end
collection do collection do

@ -3,4 +3,6 @@
:logfile: log/sidekiq.log :logfile: log/sidekiq.log
:queues: :queues:
- [default, 3] - [default, 3]
- [score, 4]
- [evaluation_comment, 5]
- [notify, 100] - [notify, 100]

@ -0,0 +1,6 @@
class ModifyQuotesForGtopicBanks < ActiveRecord::Migration[5.2]
def change
GtopicBank.where("quotes is null").update_all(:quotes => 0)
change_column :gtopic_banks, :quotes, :integer, :default => 0
end
end

@ -22,7 +22,7 @@
http://121.199.19.206:9000/api/fork_repository http://121.199.19.206:9000/api/fork_repository
参数: 参数:
{repo_path: 'Hjqreturn/aaass1.git', fork_repository_path: 'educoder/ca9fvobr.git'} {repo_path: 'Hjqreturn/aaass1.git', fork_repository_path: 'educoder/ca9fvobr.git'}
说明fork_repository_path是源项目的repo_path, repo_path是新项目的 说明fork_repository_path是新项目的repo_path, repo_path是源项目的
4、更新文件 4、更新文件
@ -41,7 +41,7 @@
5、获取文件内容 5、获取文件内容
访问地址http://121.199.19.206:9000/api/file_content 访问地址http://121.199.19.206:9000/api/file_content
参数: 参数:
{repo_path: "educoder/ca9fvobr.git", file_path: 'step1/main.py',} {repo_path: "educoder/ca9fvobr.git", path: 'step1/main.py',}
6、获取提交记录 6、获取提交记录
访问地址http://121.199.19.206:9000/api/commits 访问地址http://121.199.19.206:9000/api/commits

@ -0,0 +1,563 @@
http://testbdgit2.educoder.net/educoder/mqex9s82.git
http://testbdgit2.educoder.net/educoder/nf9ja46l.git
http://testbdgit2.educoder.net/educoder/qmeb65oa.git
http://testbdgit2.educoder.net/educoder/748fkcya.git
http://testbdgit2.educoder.net/educoder/o7pr4f6v.git
http://testbdgit2.educoder.net/educoder/tjxnyuv6.git
http://testbdgit2.educoder.net/educoder/fp6cmstz.git
http://testbdgit2.educoder.net/educoder/eh5oxkm9.git
http://testbdgit2.educoder.net/educoder/uznmbg54.git
http://testbdgit2.educoder.net/educoder/i8utopmc.git
http://testbdgit2.educoder.net/educoder/f9ly35vz.git
http://testbdgit2.educoder.net/educoder/vnw2fg5r.git
http://testbdgit2.educoder.net/educoder/pcfhzue5.git
http://testbdgit2.educoder.net/educoder/zlg2nmcf.git
http://testbdgit2.educoder.net/educoder/klp26sqc.git
http://testbdgit2.educoder.net/educoder/y68uqmoe.git
http://testbdgit2.educoder.net/educoder/7zg5mi2r.git
http://testbdgit2.educoder.net/educoder/8g93nfvc.git
http://testbdgit2.educoder.net/educoder/mnj3srpe.git
http://testbdgit2.educoder.net/educoder/lrwsyhzc.git
http://testbdgit2.educoder.net/educoder/a2ct98o7.git
http://testbdgit2.educoder.net/educoder/hawxspqm.git
http://testbdgit2.educoder.net/educoder/pobfl4g8.git
http://testbdgit2.educoder.net/educoder/zg7e9o2y.git
http://testbdgit2.educoder.net/educoder/fsu7tkaw.git
http://testbdgit2.educoder.net/educoder/cmklt4f8.git
http://testbdgit2.educoder.net/educoder/2gt3yuen.git
http://testbdgit2.educoder.net/educoder/v3bksozu.git
http://testbdgit2.educoder.net/educoder/ku6lva8t.git
http://testbdgit2.educoder.net/educoder/g8w3nj6r.git
http://testbdgit2.educoder.net/educoder/pxlsuotc.git
http://testbdgit2.educoder.net/educoder/opv8xkjw.git
http://testbdgit2.educoder.net/educoder/stewl573.git
http://testbdgit2.educoder.net/educoder/nuj9lbwv.git
http://testbdgit2.educoder.net/educoder/r4vlju5x.git
http://testbdgit2.educoder.net/educoder/85fat9w3.git
http://testbdgit2.educoder.net/educoder/guzqi4nm.git
http://testbdgit2.educoder.net/educoder/obtfwj3e.git
http://testbdgit2.educoder.net/educoder/3ozvy5f8.git
http://testbdgit2.educoder.net/educoder/8bu9zmjy.git
http://testbdgit2.educoder.net/educoder/n489y7qt.git
http://testbdgit2.educoder.net/educoder/f3pwvrtk.git
http://testbdgit2.educoder.net/educoder/b6ljcet3.git
http://testbdgit2.educoder.net/educoder/uie9snqp.git
http://testbdgit2.educoder.net/educoder/xti6ueyf.git
http://testbdgit2.educoder.net/educoder/gwkc395l.git
http://testbdgit2.educoder.net/educoder/6a2qy98p.git
http://testbdgit2.educoder.net/educoder/2qffg3pu.git
http://testbdgit2.educoder.net/educoder/nfypjxhl.git
http://testbdgit2.educoder.net/educoder/9p4neovc.git
http://testbdgit2.educoder.net/educoder/k4wg9b32.git
http://testbdgit2.educoder.net/educoder/pw53ln4m.git
http://testbdgit2.educoder.net/educoder/cylj7vgb.git
http://testbdgit2.educoder.net/educoder/ftfzbw72.git
http://testbdgit2.educoder.net/educoder/qt78x4a5.git
http://testbdgit2.educoder.net/educoder/qsza57pj.git
http://testbdgit2.educoder.net/educoder/afvk9r35.git
http://testbdgit2.educoder.net/educoder/68rqajhy.git
http://testbdgit2.educoder.net/educoder/q4ixftoz.git
http://testbdgit2.educoder.net/educoder/pbmkl5vt.git
http://testbdgit2.educoder.net/educoder/ral8fjw9.git
http://testbdgit2.educoder.net/educoder/89zfsjbp.git
http://testbdgit2.educoder.net/educoder/no9uv3g2.git
http://testbdgit2.educoder.net/educoder/cztux23y.git
http://testbdgit2.educoder.net/educoder/4bflgcs8.git
http://testbdgit2.educoder.net/educoder/6w2xmtls.git
http://testbdgit2.educoder.net/educoder/o4xa93mc.git
http://testbdgit2.educoder.net/educoder/uctzevfx.git
http://testbdgit2.educoder.net/educoder/wokspmut.git
http://testbdgit2.educoder.net/educoder/ba56rk8v.git
http://testbdgit2.educoder.net/educoder/6w49utr2.git
http://testbdgit2.educoder.net/educoder/qnubm248.git
http://testbdgit2.educoder.net/educoder/itzexlbn.git
http://testbdgit2.educoder.net/educoder/e6o9pmz4.git
http://testbdgit2.educoder.net/educoder/qr9fhylp.git
http://testbdgit2.educoder.net/educoder/q2nya3cj.git
http://testbdgit2.educoder.net/educoder/58drwg63.git
http://testbdgit2.educoder.net/educoder/oiwsvgpf.git
http://testbdgit2.educoder.net/educoder/4uyn5ebp.git
http://testbdgit2.educoder.net/educoder/pebvjtk9.git
http://testbdgit2.educoder.net/educoder/uywljq4v.git
http://testbdgit2.educoder.net/educoder/zawfjtnm.git
http://testbdgit2.educoder.net/educoder/z5w3gbhk.git
http://testbdgit2.educoder.net/educoder/cz7yw3en.git
http://testbdgit2.educoder.net/educoder/p87sflg2.git
http://testbdgit2.educoder.net/educoder/w3vcokrg.git
http://testbdgit2.educoder.net/educoder/uc64f2qs.git
http://testbdgit2.educoder.net/educoder/vtnag4op.git
http://testbdgit2.educoder.net/educoder/mbgfitn6.git
http://testbdgit2.educoder.net/educoder/nwj4ua2k.git
http://testbdgit2.educoder.net/educoder/y8kfhtu6.git
http://testbdgit2.educoder.net/educoder/tmivlph2.git
http://testbdgit2.educoder.net/educoder/ziyft572.git
http://testbdgit2.educoder.net/educoder/k8u4nrj6.git
http://testbdgit2.educoder.net/educoder/wgfyrzhe.git
http://testbdgit2.educoder.net/educoder/a4ts237c.git
http://testbdgit2.educoder.net/educoder/cvw63y9e.git
http://testbdgit2.educoder.net/educoder/bxltfpa5.git
http://testbdgit2.educoder.net/educoder/x2anczf5.git
http://testbdgit2.educoder.net/educoder/m57iyhan.git
http://testbdgit2.educoder.net/educoder/iqrakwl2.git
http://testbdgit2.educoder.net/educoder/fagcx7yl.git
http://testbdgit2.educoder.net/educoder/oxlpy9uq.git
http://testbdgit2.educoder.net/educoder/6spm2y7k.git
http://testbdgit2.educoder.net/educoder/6fxzts5b.git
http://testbdgit2.educoder.net/eduforge/fhc7p56a.git
http://testbdgit2.educoder.net/eduforge/3aexl5my.git
http://testbdgit2.educoder.net/educoder/9mz7qn5t.git
http://testbdgit2.educoder.net/educoder/b9r8pon3.git
http://testbdgit2.educoder.net/educoder/ciz68os9.git
http://testbdgit2.educoder.net/educoder/2e4fuw87.git
http://testbdgit2.educoder.net/educoder/hwm9s64y.git
http://testbdgit2.educoder.net/educoder/owsik483.git
http://testbdgit2.educoder.net/educoder/pbt9cyfo.git
http://testbdgit2.educoder.net/educoder/8u4fvn9w.git
http://testbdgit2.educoder.net/educoder/5bpkg3e6.git
http://testbdgit2.educoder.net/educoder/ohkunqe2.git
http://testbdgit2.educoder.net/educoder/u3j28qe6.git
http://testbdgit2.educoder.net/educoder/yjo3t72c.git
http://testbdgit2.educoder.net/educoder/oy7prsxe.git
http://testbdgit2.educoder.net/educoder/q3ljmkn2.git
http://testbdgit2.educoder.net/educoder/gk6lhtrf.git
http://testbdgit2.educoder.net/eduforge/v6pa2kiz.git
http://testbdgit2.educoder.net/educoder/qpuobn24.git
http://testbdgit2.educoder.net/educoder/mkxfysza.git
http://testbdgit2.educoder.net/eduforge/hpr7ojgc.git
http://testbdgit2.educoder.net/educoder/2aef9wni.git
http://testbdgit2.educoder.net/eduforge/8texrqwj.git
http://testbdgit2.educoder.net/educoder/wle7zmxu.git
http://testbdgit2.educoder.net/eduforge/j7cx68b9.git
http://testbdgit2.educoder.net/educoder/ywrcjki2.git
http://testbdgit2.educoder.net/educoder/sauvl9px.git
http://testbdgit2.educoder.net/educoder/3pl6j2me.git
http://testbdgit2.educoder.net/eduforge/o53rjgsh.git
http://testbdgit2.educoder.net/educoder/g8znf6cy.git
http://testbdgit2.educoder.net/educoder/itk4hy6l.git
http://testbdgit2.educoder.net/eduforge/igbc4rtw.git
http://testbdgit2.educoder.net/educoder/mnkfuyvx.git
http://testbdgit2.educoder.net/educoder/oatsh64e.git
http://testbdgit2.educoder.net/educoder/2mgsyrnu.git
http://testbdgit2.educoder.net/educoder/69ulmat5.git
http://testbdgit2.educoder.net/eduforge/9z3k5i4f.git
http://testbdgit2.educoder.net/educoder/7bysthvr.git
http://testbdgit2.educoder.net/eduforge/z3wh7uex.git
http://testbdgit2.educoder.net/educoder/9o5h2rsf.git
http://testbdgit2.educoder.net/educoder/uf3gl2vq.git
http://testbdgit2.educoder.net/eduforge/jef9xvzb.git
http://testbdgit2.educoder.net/educoder/g94qce7p.git
http://testbdgit2.educoder.net/educoder/2a54vk8x.git
http://testbdgit2.educoder.net/educoder/sx5eukfq.git
http://testbdgit2.educoder.net/educoder/ivzjw793.git
http://testbdgit2.educoder.net/eduforge/aekgf6pz.git
http://testbdgit2.educoder.net/educoder/tzqbu6c4.git
http://testbdgit2.educoder.net/educoder/ovz3e6a7.git
http://testbdgit2.educoder.net/educoder/ujavffi2.git
http://testbdgit2.educoder.net/educoder/8jsxcfm5.git
http://testbdgit2.educoder.net/educoder/qgpycjvn.git
http://testbdgit2.educoder.net/educoder/rhasift3.git
http://testbdgit2.educoder.net/educoder/nfpla5jg.git
http://testbdgit2.educoder.net/educoder/bjo2x4c9.git
http://testbdgit2.educoder.net/educoder/3jawxy9g.git
http://testbdgit2.educoder.net/eduforge/h6gs8t7q.git
http://testbdgit2.educoder.net/educoder/ntexhzrl.git
http://testbdgit2.educoder.net/educoder/jft327sa.git
http://testbdgit2.educoder.net/educoder/7bvs54gw.git
http://testbdgit2.educoder.net/educoder/grunzcs3.git
http://testbdgit2.educoder.net/educoder/q4fowkfa.git
http://testbdgit2.educoder.net/educoder/fkmtrpsn.git
http://testbdgit2.educoder.net/educoder/2iubzxfh.git
http://testbdgit2.educoder.net/educoder/gbhwvrki.git
http://testbdgit2.educoder.net/educoder/kpxfs4b5.git
http://testbdgit2.educoder.net/educoder/h5f6wi7x.git
http://testbdgit2.educoder.net/educoder/c3lr2xjz.git
http://testbdgit2.educoder.net/educoder/q8bcyxz3.git
http://testbdgit2.educoder.net/educoder/qha5emif.git
http://testbdgit2.educoder.net/educoder/5jr4gzs7.git
http://testbdgit2.educoder.net/educoder/9ksg4up7.git
http://testbdgit2.educoder.net/educoder/4rcxvftu.git
http://testbdgit2.educoder.net/educoder/hvaf5txj.git
http://testbdgit2.educoder.net/educoder/b4vqe8uz.git
http://testbdgit2.educoder.net/educoder/pg6c2i5y.git
http://testbdgit2.educoder.net/educoder/fbtlw8ro.git
http://testbdgit2.educoder.net/educoder/86f92lri.git
http://testbdgit2.educoder.net/educoder/zvaup9yo.git
http://testbdgit2.educoder.net/educoder/exm3ffap.git
http://testbdgit2.educoder.net/educoder/owg63ezu.git
http://testbdgit2.educoder.net/educoder/c36opqaj.git
http://testbdgit2.educoder.net/educoder/xuyrc6qs.git
http://testbdgit2.educoder.net/educoder/xc9tj82p.git
http://testbdgit2.educoder.net/educoder/nmougtya.git
http://testbdgit2.educoder.net/educoder/8arufxzl.git
http://testbdgit2.educoder.net/educoder/m7nrf6zf.git
http://testbdgit2.educoder.net/educoder/zffu9j6v.git
http://testbdgit2.educoder.net/educoder/epmtoh6b.git
http://testbdgit2.educoder.net/educoder/ejab7vxn.git
http://testbdgit2.educoder.net/educoder/83lyhsen.git
http://testbdgit2.educoder.net/educoder/m4e6x573.git
http://testbdgit2.educoder.net/educoder/unfihtsv.git
http://testbdgit2.educoder.net/educoder/74ftapwb.git
http://testbdgit2.educoder.net/educoder/iu47m9qx.git
http://testbdgit2.educoder.net/educoder/8bh6mfu3.git
http://testbdgit2.educoder.net/educoder/sb26oath.git
http://testbdgit2.educoder.net/educoder/igvm3fsb.git
http://testbdgit2.educoder.net/educoder/gancv2yo.git
http://testbdgit2.educoder.net/educoder/kyp65jwu.git
http://testbdgit2.educoder.net/educoder/6ru2nbpj.git
http://testbdgit2.educoder.net/educoder/rfpwhsu5.git
http://testbdgit2.educoder.net/educoder/orem2wgc.git
http://testbdgit2.educoder.net/educoder/yuhmfliq.git
http://testbdgit2.educoder.net/educoder/m4c7jo6y.git
http://testbdgit2.educoder.net/educoder/5l6oufzc.git
http://testbdgit2.educoder.net/educoder/my7vcffx.git
http://testbdgit2.educoder.net/educoder/uvka63xs.git
http://testbdgit2.educoder.net/educoder/c9thq3li.git
http://testbdgit2.educoder.net/educoder/o45rn2sl.git
http://testbdgit2.educoder.net/educoder/sae3fyjc.git
http://testbdgit2.educoder.net/educoder/56orxtg3.git
http://testbdgit2.educoder.net/educoder/cqpzx47f.git
http://testbdgit2.educoder.net/educoder/2in3vcf7.git
http://testbdgit2.educoder.net/educoder/6isfgtun.git
http://testbdgit2.educoder.net/educoder/46woubzq.git
http://testbdgit2.educoder.net/educoder/6xwmi29f.git
http://testbdgit2.educoder.net/educoder/hk968fua.git
http://testbdgit2.educoder.net/educoder/ogb6ixjz.git
http://testbdgit2.educoder.net/educoder/va7cru64.git
http://testbdgit2.educoder.net/educoder/vqnk5tjo.git
http://testbdgit2.educoder.net/educoder/oqfsci8u.git
http://testbdgit2.educoder.net/educoder/qcosi4f8.git
http://testbdgit2.educoder.net/educoder/bsnk7wit.git
http://testbdgit2.educoder.net/educoder/ksvmtwql.git
http://testbdgit2.educoder.net/educoder/eigqpfua.git
http://testbdgit2.educoder.net/educoder/hqmwxztb.git
http://testbdgit2.educoder.net/educoder/jlgt9wfk.git
http://testbdgit2.educoder.net/educoder/hcuzqkgv.git
http://testbdgit2.educoder.net/educoder/hzw89pof.git
http://testbdgit2.educoder.net/educoder/xnft4fsm.git
http://testbdgit2.educoder.net/educoder/guj4ml8q.git
http://testbdgit2.educoder.net/educoder/l56jkwfn.git
http://testbdgit2.educoder.net/educoder/4jqry5gl.git
http://testbdgit2.educoder.net/educoder/65kiwb72.git
http://testbdgit2.educoder.net/educoder/xb39mzfr.git
http://testbdgit2.educoder.net/educoder/hyb5m38x.git
http://testbdgit2.educoder.net/educoder/p4f2jtkq.git
http://testbdgit2.educoder.net/educoder/4n3stcol.git
http://testbdgit2.educoder.net/educoder/6kjqar5e.git
http://testbdgit2.educoder.net/educoder/qhc2prk4.git
http://testbdgit2.educoder.net/educoder/ltw8b29i.git
http://testbdgit2.educoder.net/educoder/g5y8zcvl.git
http://testbdgit2.educoder.net/educoder/5et7zpra.git
http://testbdgit2.educoder.net/educoder/au97mpbr.git
http://testbdgit2.educoder.net/educoder/oxmt2zvc.git
http://testbdgit2.educoder.net/educoder/26chou4y.git
http://testbdgit2.educoder.net/educoder/lfmus7o2.git
http://testbdgit2.educoder.net/educoder/efbp7luz.git
http://testbdgit2.educoder.net/educoder/7lr8agws.git
http://testbdgit2.educoder.net/educoder/ak8tbjuv.git
http://testbdgit2.educoder.net/educoder/qu8a93ew.git
http://testbdgit2.educoder.net/educoder/zlgfiowe.git
http://testbdgit2.educoder.net/educoder/qmt4nfai.git
http://testbdgit2.educoder.net/educoder/u2s4v9ba.git
http://testbdgit2.educoder.net/educoder/2icxsunf.git
http://testbdgit2.educoder.net/educoder/fzmqjp6g.git
http://testbdgit2.educoder.net/educoder/7ir3vmzw.git
http://testbdgit2.educoder.net/educoder/xkfzg96o.git
http://testbdgit2.educoder.net/educoder/xvfl5sjz.git
http://testbdgit2.educoder.net/educoder/qnwuy7h3.git
http://testbdgit2.educoder.net/educoder/bhnspvmg.git
http://testbdgit2.educoder.net/educoder/ns7vh6ro.git
http://testbdgit2.educoder.net/eduforge/un3xoal7.git
http://testbdgit2.educoder.net/educoder/29am7wv4.git
http://testbdgit2.educoder.net/educoder/qlfn5hiu.git
http://testbdgit2.educoder.net/educoder/e4pvkhtj.git
http://testbdgit2.educoder.net/educoder/hfesmtuz.git
http://testbdgit2.educoder.net/educoder/6kjhil3m.git
http://testbdgit2.educoder.net/educoder/2igrh8c4.git
http://testbdgit2.educoder.net/educoder/e7yt3kmw.git
http://testbdgit2.educoder.net/educoder/a8zybrkt.git
http://testbdgit2.educoder.net/educoder/v2uzrasj.git
http://testbdgit2.educoder.net/educoder/rb83htif.git
http://testbdgit2.educoder.net/eduforge/jc3p2wto.git
http://testbdgit2.educoder.net/educoder/jtnlfgw2.git
http://testbdgit2.educoder.net/educoder/fa96xrti.git
http://testbdgit2.educoder.net/educoder/r6bjga3u.git
http://testbdgit2.educoder.net/educoder/fpmwzxqn.git
http://testbdgit2.educoder.net/educoder/rbpsw8ct.git
http://testbdgit2.educoder.net/educoder/4zuxembp.git
http://testbdgit2.educoder.net/educoder/3gxwrzaf.git
http://testbdgit2.educoder.net/educoder/wz6j5lpn.git
http://testbdgit2.educoder.net/educoder/izu9tf3j.git
http://testbdgit2.educoder.net/educoder/vhux4pa7.git
http://testbdgit2.educoder.net/educoder/s9wvroqn.git
http://testbdgit2.educoder.net/educoder/ruofj2xl.git
http://testbdgit2.educoder.net/educoder/qj4mlxoi.git
http://testbdgit2.educoder.net/educoder/34gzbolc.git
http://testbdgit2.educoder.net/educoder/at86wfsn.git
http://testbdgit2.educoder.net/educoder/j7fnwsrh.git
http://testbdgit2.educoder.net/educoder/zgsuk364.git
http://testbdgit2.educoder.net/educoder/nf3gv54x.git
http://testbdgit2.educoder.net/educoder/fnbuq957.git
http://testbdgit2.educoder.net/educoder/z4fp9o3e.git
http://testbdgit2.educoder.net/educoder/c3qh4p6f.git
http://testbdgit2.educoder.net/educoder/fszntcbw.git
http://testbdgit2.educoder.net/educoder/af968lnf.git
http://testbdgit2.educoder.net/educoder/kpc36fhn.git
http://testbdgit2.educoder.net/educoder/6c4wp5bu.git
http://testbdgit2.educoder.net/educoder/hzmikncs.git
http://testbdgit2.educoder.net/educoder/6ogr4bhj.git
http://testbdgit2.educoder.net/educoder/fu59rezf.git
http://testbdgit2.educoder.net/educoder/zef9gswv.git
http://testbdgit2.educoder.net/educoder/p9z4fxv8.git
http://testbdgit2.educoder.net/eduforge/hcxeuyfl.git
http://testbdgit2.educoder.net/educoder/4u2ebx89.git
http://testbdgit2.educoder.net/educoder/cikojzsb.git
http://testbdgit2.educoder.net/educoder/2rzomtx5.git
http://testbdgit2.educoder.net/educoder/wfvbhr2s.git
http://testbdgit2.educoder.net/educoder/q8mxg4zv.git
http://testbdgit2.educoder.net/educoder/q8fezi37.git
http://testbdgit2.educoder.net/educoder/nb7ha8te.git
http://testbdgit2.educoder.net/educoder/qxgfbyn9.git
http://testbdgit2.educoder.net/educoder/k8so9wa2.git
http://testbdgit2.educoder.net/educoder/zwc9ja5y.git
http://testbdgit2.educoder.net/educoder/89lwscfy.git
http://testbdgit2.educoder.net/educoder/ga26fy4f.git
http://testbdgit2.educoder.net/educoder/rgy4769i.git
http://testbdgit2.educoder.net/educoder/q3rnovik.git
http://testbdgit2.educoder.net/educoder/r5xsukn4.git
http://testbdgit2.educoder.net/educoder/yu6za47j.git
http://testbdgit2.educoder.net/educoder/fqvr56nm.git
http://testbdgit2.educoder.net/educoder/tq26m73o.git
http://testbdgit2.educoder.net/educoder/k2rmpuf6.git
http://testbdgit2.educoder.net/educoder/fzg87ip6.git
http://testbdgit2.educoder.net/educoder/qk3l64zi.git
http://testbdgit2.educoder.net/educoder/bcjpk93f.git
http://testbdgit2.educoder.net/educoder/rnjak48l.git
http://testbdgit2.educoder.net/educoder/hyzkq5vr.git
http://testbdgit2.educoder.net/educoder/tqnvbisr.git
http://testbdgit2.educoder.net/educoder/nfszy26f.git
http://testbdgit2.educoder.net/educoder/rfnhkvgo.git
http://testbdgit2.educoder.net/educoder/6omf2gbl.git
http://testbdgit2.educoder.net/educoder/x4qhb5k7.git
http://testbdgit2.educoder.net/educoder/jyz63ge5.git
http://testbdgit2.educoder.net/educoder/hfqwilp3.git
http://testbdgit2.educoder.net/educoder/aq9c4fy5.git
http://testbdgit2.educoder.net/educoder/tzshnbl8.git
http://testbdgit2.educoder.net/educoder/zm8qffrj.git
http://testbdgit2.educoder.net/educoder/szctor3e.git
http://testbdgit2.educoder.net/educoder/amcyzpvk.git
http://testbdgit2.educoder.net/educoder/fpy467o9.git
http://testbdgit2.educoder.net/educoder/w5nytxec.git
http://testbdgit2.educoder.net/educoder/icreqzu4.git
http://testbdgit2.educoder.net/educoder/2jf76xr5.git
http://testbdgit2.educoder.net/educoder/yl4a2qf5.git
http://testbdgit2.educoder.net/educoder/jgmcieqk.git
http://testbdgit2.educoder.net/educoder/hjtxy657.git
http://testbdgit2.educoder.net/educoder/47w6uyeh.git
http://testbdgit2.educoder.net/educoder/pr4vg7j5.git
http://testbdgit2.educoder.net/educoder/m6xn7z93.git
http://testbdgit2.educoder.net/educoder/f23fge9h.git
http://testbdgit2.educoder.net/educoder/cfo7lqhs.git
http://testbdgit2.educoder.net/educoder/4gnkqf3y.git
http://testbdgit2.educoder.net/educoder/k89bgonj.git
http://testbdgit2.educoder.net/educoder/k98qr7iw.git
http://testbdgit2.educoder.net/educoder/jel85v62.git
http://testbdgit2.educoder.net/educoder/zt2aqnb6.git
http://testbdgit2.educoder.net/educoder/7icqubfj.git
http://testbdgit2.educoder.net/educoder/2x59s3by.git
http://testbdgit2.educoder.net/educoder/mrvwxekj.git
http://testbdgit2.educoder.net/educoder/k5cruoyp.git
http://testbdgit2.educoder.net/educoder/rc6hw58u.git
http://testbdgit2.educoder.net/educoder/ygzf7v3k.git
http://testbdgit2.educoder.net/educoder/8ty6fgln.git
http://testbdgit2.educoder.net/educoder/wp5mbjg8.git
http://testbdgit2.educoder.net/educoder/oniuafxz.git
http://testbdgit2.educoder.net/educoder/aviljpmn.git
http://testbdgit2.educoder.net/educoder/iufg8573.git
http://testbdgit2.educoder.net/educoder/gc8xl2v9.git
http://testbdgit2.educoder.net/educoder/2wgmhvuk.git
http://testbdgit2.educoder.net/educoder/clx7ha6j.git
http://testbdgit2.educoder.net/educoder/bz9wxpvr.git
http://testbdgit2.educoder.net/educoder/uw95cg28.git
http://testbdgit2.educoder.net/educoder/4frpc7ix.git
http://testbdgit2.educoder.net/educoder/nas3v78t.git
http://testbdgit2.educoder.net/educoder/cbrys8f3.git
http://testbdgit2.educoder.net/educoder/ofj29enq.git
http://testbdgit2.educoder.net/educoder/btvk2w5h.git
http://testbdgit2.educoder.net/educoder/cztbjan5.git
http://testbdgit2.educoder.net/educoder/7atfm9vu.git
http://testbdgit2.educoder.net/educoder/cpxs3kfu.git
http://testbdgit2.educoder.net/educoder/5pfalzkh.git
http://testbdgit2.educoder.net/educoder/yf6covh2.git
http://testbdgit2.educoder.net/educoder/ocevha8x.git
http://testbdgit2.educoder.net/educoder/qtxkogfi.git
http://testbdgit2.educoder.net/educoder/pa8fh4m2.git
http://testbdgit2.educoder.net/educoder/n3ps8i4m.git
http://testbdgit2.educoder.net/educoder/5x9alvmc.git
http://testbdgit2.educoder.net/educoder/yl732ofk.git
http://testbdgit2.educoder.net/educoder/hvlgfjb7.git
http://testbdgit2.educoder.net/educoder/i9sfum58.git
http://testbdgit2.educoder.net/educoder/my9jcvio.git
http://testbdgit2.educoder.net/educoder/2myqxbce.git
http://testbdgit2.educoder.net/educoder/p4x9qmka.git
http://testbdgit2.educoder.net/educoder/aslcogwk.git
http://testbdgit2.educoder.net/educoder/eryg8fot.git
http://testbdgit2.educoder.net/educoder/ust5hgjm.git
http://testbdgit2.educoder.net/educoder/ypve8gbo.git
http://testbdgit2.educoder.net/educoder/ir768pfq.git
http://testbdgit2.educoder.net/educoder/ki98yelu.git
http://testbdgit2.educoder.net/educoder/i4nzvb7x.git
http://testbdgit2.educoder.net/educoder/58l7vb9f.git
http://testbdgit2.educoder.net/educoder/l859pqs3.git
http://testbdgit2.educoder.net/educoder/6rvpzn7x.git
http://testbdgit2.educoder.net/educoder/c5msxfe8.git
http://testbdgit2.educoder.net/educoder/cwa6igze.git
http://testbdgit2.educoder.net/educoder/vbnqglcw.git
http://testbdgit2.educoder.net/educoder/8bysvmcf.git
http://testbdgit2.educoder.net/educoder/u3ceh2xw.git
http://testbdgit2.educoder.net/educoder/heqtnza3.git
http://testbdgit2.educoder.net/educoder/uzoltjva.git
http://testbdgit2.educoder.net/educoder/mefykafs.git
http://testbdgit2.educoder.net/educoder/6jvypwgq.git
http://testbdgit2.educoder.net/educoder/h5wisac9.git
http://testbdgit2.educoder.net/educoder/52ufjw9m.git
http://testbdgit2.educoder.net/educoder/v2uxoifl.git
http://testbdgit2.educoder.net/educoder/an2ofy6k.git
http://testbdgit2.educoder.net/educoder/kao2rlf5.git
http://testbdgit2.educoder.net/educoder/uihap3wr.git
http://testbdgit2.educoder.net/educoder/wliam3nq.git
http://testbdgit2.educoder.net/educoder/7cpo6hel.git
http://testbdgit2.educoder.net/educoder/bmtlph7e.git
http://testbdgit2.educoder.net/educoder/b8n9twpf.git
http://testbdgit2.educoder.net/educoder/3cur5wz6.git
http://testbdgit2.educoder.net/educoder/h6ga29wv.git
http://testbdgit2.educoder.net/educoder/67kv4zmg.git
http://testbdgit2.educoder.net/educoder/buf6h8jf.git
http://testbdgit2.educoder.net/educoder/gce9ojqv.git
http://testbdgit2.educoder.net/educoder/jm2l6rwf.git
http://testbdgit2.educoder.net/educoder/4lwfjfrt.git
http://testbdgit2.educoder.net/educoder/5qsw32oj.git
http://testbdgit2.educoder.net/educoder/9yw36vxq.git
http://testbdgit2.educoder.net/educoder/93fivo6k.git
http://testbdgit2.educoder.net/educoder/nwy3x4t2.git
http://testbdgit2.educoder.net/educoder/ku9o2fcf.git
http://testbdgit2.educoder.net/educoder/s68uqlic.git
http://testbdgit2.educoder.net/educoder/4bajyohg.git
http://testbdgit2.educoder.net/educoder/qtfpscz8.git
http://testbdgit2.educoder.net/educoder/j5u7y6wn.git
http://testbdgit2.educoder.net/educoder/btku8vcx.git
http://testbdgit2.educoder.net/educoder/a9n8w2eu.git
http://testbdgit2.educoder.net/educoder/vze7ny25.git
http://testbdgit2.educoder.net/educoder/yz5aofe2.git
http://testbdgit2.educoder.net/educoder/r9nibvz4.git
http://testbdgit2.educoder.net/educoder/6cvxk3q8.git
http://testbdgit2.educoder.net/educoder/rmtuvk6z.git
http://testbdgit2.educoder.net/educoder/sbitr936.git
http://testbdgit2.educoder.net/educoder/sb6j4raf.git
http://testbdgit2.educoder.net/educoder/a7gfvh5s.git
http://testbdgit2.educoder.net/educoder/zsj6ao3c.git
http://testbdgit2.educoder.net/educoder/8x2epwk6.git
http://testbdgit2.educoder.net/educoder/cbnfxeiw.git
http://testbdgit2.educoder.net/educoder/ul47bqcn.git
http://testbdgit2.educoder.net/educoder/ltsnfy4x.git
http://testbdgit2.educoder.net/educoder/t53nvo8e.git
http://testbdgit2.educoder.net/educoder/yojwp2mb.git
http://testbdgit2.educoder.net/educoder/67nayvtg.git
http://testbdgit2.educoder.net/educoder/42fq3yx7.git
http://testbdgit2.educoder.net/educoder/f39hiscw.git
http://testbdgit2.educoder.net/educoder/jey9avks.git
http://testbdgit2.educoder.net/educoder/ascbpy86.git
http://testbdgit2.educoder.net/educoder/vagzfryl.git
http://testbdgit2.educoder.net/educoder/c6k5i82o.git
http://testbdgit2.educoder.net/educoder/utr8bp9a.git
http://testbdgit2.educoder.net/educoder/ul65ap4o.git
http://testbdgit2.educoder.net/educoder/bmulap4n.git
http://testbdgit2.educoder.net/educoder/nxj2sfvr.git
http://testbdgit2.educoder.net/educoder/vq5t9hea.git
http://testbdgit2.educoder.net/educoder/7g5l6kzr.git
http://testbdgit2.educoder.net/educoder/2y8t594n.git
http://testbdgit2.educoder.net/educoder/mlnpqx9r.git
http://testbdgit2.educoder.net/educoder/apgxmqs7.git
http://testbdgit2.educoder.net/educoder/vur567ha.git
http://testbdgit2.educoder.net/educoder/qwctfpjl.git
http://testbdgit2.educoder.net/educoder/5w6gh9m8.git
http://testbdgit2.educoder.net/educoder/fzhe4mpv.git
http://testbdgit2.educoder.net/educoder/vmygstfb.git
http://testbdgit2.educoder.net/educoder/uryh3e4i.git
http://testbdgit2.educoder.net/educoder/nbixuzkf.git
http://testbdgit2.educoder.net/educoder/zpkyj7bs.git
http://testbdgit2.educoder.net/educoder/79tpk5oy.git
http://testbdgit2.educoder.net/educoder/s93x58at.git
http://testbdgit2.educoder.net/educoder/6ymec92a.git
http://testbdgit2.educoder.net/educoder/7vqgbsfc.git
http://testbdgit2.educoder.net/educoder/fr5fom8n.git
http://testbdgit2.educoder.net/educoder/7uzyskn9.git
http://testbdgit2.educoder.net/educoder/g4fvywf6.git
http://testbdgit2.educoder.net/educoder/wa98h2ly.git
http://testbdgit2.educoder.net/educoder/u6i2o3qz.git
http://testbdgit2.educoder.net/educoder/enxbyiok.git
http://testbdgit2.educoder.net/educoder/2fuweqf8.git
http://testbdgit2.educoder.net/educoder/48flws5g.git
http://testbdgit2.educoder.net/educoder/yugrij4n.git
http://testbdgit2.educoder.net/educoder/gtbkvm58.git
http://testbdgit2.educoder.net/educoder/nes73wfv.git
http://testbdgit2.educoder.net/educoder/oztyjl4h.git
http://testbdgit2.educoder.net/educoder/f398leqr.git
http://testbdgit2.educoder.net/educoder/i3xutoze.git
http://testbdgit2.educoder.net/educoder/mfv6zrj7.git
http://testbdgit2.educoder.net/educoder/6ujfeqbh.git
http://testbdgit2.educoder.net/educoder/8x93tfqn.git
http://testbdgit2.educoder.net/educoder/fxv9bpcw.git
http://testbdgit2.educoder.net/eduforge/64xb9k2q.git
http://testbdgit2.educoder.net/educoder/5e4vcr7t.git
http://testbdgit2.educoder.net/educoder/qwaffs2p.git
http://testbdgit2.educoder.net/educoder/ose7482b.git
http://testbdgit2.educoder.net/educoder/wt2xfzny.git
http://testbdgit2.educoder.net/educoder/cuqnpzjv.git
http://testbdgit2.educoder.net/educoder/n3a8q9b2.git
http://testbdgit2.educoder.net/educoder/f9o4hpix.git
http://testbdgit2.educoder.net/educoder/bm9qr7ue.git
http://testbdgit2.educoder.net/educoder/nhlygi7p.git
http://testbdgit2.educoder.net/educoder/mf2vfngu.git
http://testbdgit2.educoder.net/educoder/x6tsevzy.git
http://testbdgit2.educoder.net/educoder/rjfbm74o.git
http://testbdgit2.educoder.net/educoder/ztbukf7e.git
http://testbdgit2.educoder.net/educoder/pf8yze9h.git
http://testbdgit2.educoder.net/educoder/nrug2mfz.git
http://testbdgit2.educoder.net/educoder/jswmzaxr.git
http://testbdgit2.educoder.net/educoder/wpxjzo3c.git
http://testbdgit2.educoder.net/educoder/zaohblre.git
http://testbdgit2.educoder.net/educoder/psx2h9kf.git
http://testbdgit2.educoder.net/educoder/ayju6fie.git
http://testbdgit2.educoder.net/educoder/5kp9guol.git
http://testbdgit2.educoder.net/educoder/c4ztkfb2.git
http://testbdgit2.educoder.net/educoder/kboupjtl.git
http://testbdgit2.educoder.net/educoder/bcvhs9u7.git
http://testbdgit2.educoder.net/educoder/26vljnb3.git
http://testbdgit2.educoder.net/educoder/zesqa3wi.git
http://testbdgit2.educoder.net/educoder/43phxgsf.git
http://testbdgit2.educoder.net/educoder/fbx6awcm.git
http://testbdgit2.educoder.net/educoder/i2s7jof5.git
http://testbdgit2.educoder.net/educoder/n2w4jrax.git
http://testbdgit2.educoder.net/educoder/4pou5tey.git
http://testbdgit2.educoder.net/eduforge/e9qr7cxi.git
http://testbdgit2.educoder.net/educoder/y6bg739q.git
http://testbdgit2.educoder.net/educoder/h32r58s7.git
http://testbdgit2.educoder.net/eduforge/hpr7ojgc-1.git
http://testbdgit2.educoder.net/educoder/c3j4hufp.git
http://testbdgit2.educoder.net/eduforge/o72clmi4.git
http://testbdgit2.educoder.net/educoder/qfz8o2r6.git
http://testbdgit2.educoder.net/educoder/rw3i8vf2.git
http://testbdgit2.educoder.net/educoder/shpwf3xf.git
http://testbdgit2.educoder.net/eduforge/vnw2fg5r.git
http://testbdgit2.educoder.net/innov/f2izon59.git
http://testbdgit2.educoder.net/innov/qlkpiusm.git
http://testbdgit2.educoder.net/innov/edu1547017399.git
http://testbdgit2.educoder.net/forge01/cermyt39.git
http://testbdgit2.educoder.net/innov/em3z8yn6.git
http://testbdgit2.educoder.net/innov/c8ynf526.git
http://testbdgit2.educoder.net/Hjqreturn/sx36oveq.git
http://testbdgit2.educoder.net/innov/t7sxkfab20190115135957.git
http://testbdgit2.educoder.net/innov/etlb3pn620190115140004.git
http://testbdgit2.educoder.net/innov/5jbomfrg20190115140011.git
http://testbdgit2.educoder.net/innov/6ecmbf7g20190115140015.git
http://testbdgit2.educoder.net/innov/f7jn8kex20190115140330.git

@ -0,0 +1,72 @@
mbtclufr
9op3hs4j
96ctv7yr
rtmzxfke
ofqxthrf
czu9w4gj
9fpzj6et
pwhc865b
maozpx4l
y5wh2ofx
b5rzhpf3
bs243nrl
47fn2yfb
kwotfxey
w5468sbp
fyekprio
q6ze5fih
b5hjq9zm
ky8pbqux
53phc7nq
b9j2yuix
9t3uphwk
iokm8ah2
qlsy6xb4
345bqhfi
v728fqia
4euftvf2
f23sef5m
nhqis8m9
qp72tb5x
gt3anszw
tng6heyf
nb9keawo
elgnbkp9
4neslomg
lh35s6ma
xmc4rpay
qrpaxi6b
9fla2zry
efuibzrm
fzp3iu4w
pligsyn8
glbksr29
kfm7ghyc
p6hk3svf
p539gjhm
am5o73er
4x3qwrbe
fqosyl8g
of5z3fci
tb7hw62n
ie6zxg7r
4q2bmy9h
fpm3u5yb
nikx3ojt
vt82s9bq
ma59fefo
lxa39tfq
4gnockxf
nxwg84ey
fmie8nzb
w5nsr24v
4hn3efwc
h9ljfbq7
nuv54t8b
2te9fmfq
vihnsayz
qhlyn82s
vw74kmfr
vcta36bz
henz425l
g529v38z

@ -1,15 +1,52 @@
# 需要做的几件事:
# 1、检测两边TPM\TPI同步后有更新的仓库
#
namespace :git do namespace :git do
desc "检测是否TPM是否需要更新" desc "检测是否TPM是否需要更新"
task :shixun_check_update => :environment do task :shixun_check_update => :environment do
g = Gitlab.client
file_txt = File.new("lib/gitcheck/shixun_update.txt", "r+")
file_error_txt = File.new("lib/gitcheck/shixun_update_error.txt", "r+")
host = EduSetting.find_by_name("git_address_domain").try(:value)
Shixun.find_each do |shixun|
begin
gitlab_commit = g.commits(shixun.gpid, :ref_name => 'master').first.try(:id)
repo_name = shixun.repo_name
git_commit = GitService.commits(repo_path: "#{repo_name}.git").first["id"]
git_url = host + "/" + repo_name + ".git\n"
if git_commit != gitlab_commit
file_txt.syswrite(git_url)
end
rescue
file_error_txt.syswrite("#{shixun.identifier}\n")
end
end
end end
desc "检测版本库是否有异常" desc "检测版本库是否有更新"
task :myshixuns_check_update => :environment do task :myshixuns_check_update => :environment do
g = Gitlab.client
file_txt = File.new("lib/gitcheck/myshixun_update.txt", "r+")
file_error_txt = File.new("lib/gitcheck/myshixun_update_error.txt", "r+")
host = EduSetting.find_by_name("git_address_domain").try(:value)
Myshixun.find_each do |myshixun|
begin
gitlab_commit = g.commits(myshixun.gpid, :ref_name => 'master').first.try(:id)
repo_name = myshixun.repo_name
git_commit = GitService.commits(repo_path: "#{repo_name}.git").first["id"]
git_url = host + "/" + repo_name + ".git\n"
if git_commit != gitlab_commit
file_txt.syswrite(git_url)
end
rescue
file_error_txt.syswrite("#{myshixun.identifier}\n")
end
end
end end
# 检测TPI没有迁移过来的
task :check => :environment do task :check => :environment do
end end

@ -5,27 +5,9 @@ namespace :graduation_task do
tasks = GraduationTask.where("publish_time is not null and publish_time <= '#{Time.now}' and status = 0") tasks = GraduationTask.where("publish_time is not null and publish_time <= '#{Time.now}' and status = 0")
tasks.each do |task| tasks.each do |task|
task.update_attributes(status: 1) task.update_attributes(status: 1)
course = task.course GraduationTaskPublishNotifyJob.perform_later(task.id)
members = course.course_members
if !course.nil? && !members.empty?
tid_str = ""
members.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{task.user_id}, #{task.id}, 'GraduationTask', #{task.id}, 'TaskPublish',
#{course.id}, 'Course', 0, 'GraduationTask', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at,
updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql
end
end
if task.course_acts.size == 0 task.course_acts << CourseActivity.new(user_id: task.user_id, course_id: task.course_id) if !task.course_acts.exists?
task.course_acts << CourseActivity.new(user_id: task.user_id, course_id: task.course_id)
end
end end
end end
@ -62,37 +44,11 @@ namespace :graduation_task do
tasks = GraduationTask.where("cross_comment = 1 and comment_time is not null and comment_time <= '#{Time.now}' and status = 2") tasks = GraduationTask.where("cross_comment = 1 and comment_time is not null and comment_time <= '#{Time.now}' and status = 2")
tasks.each do |task| tasks.each do |task|
if task.comment_status == 4 if task.comment_status == 4
course = task.course GraduationTaskCrossCommentJob.perform_later(task.id)
task.graduation_task_group_assignations.each do |assignation|
graduation_group = assignation.graduation_group
assign_group = assignation.assign_group
if graduation_group.present? && assign_group.present?
course_group_ids = course.teacher_course_groups.where(course_member_id: graduation_group.course_members.pluck(:id)).pluck(:course_group_id)
graduation_works = task.graduation_works.where(user_id: course.course_members.where(:course_group_id => course_group_ids).map(&:user_id),
work_status: [1, 2])
if assign_group.course_members.count <= task.comment_num
graduation_works.each do |work|
assign_group.course_members.each do |member|
work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(
graduation_group_id: assign_group.id, user_id: member.user_id, graduation_task_id: task.id)
end
end
else
member_user_ids = assign_group.course_members.pluck(:user_id)
count = 0
graduation_works.each do |work|
for i in 1 .. task.comment_num
assign_user_id = member_user_ids[count % member_user_ids.size]
work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(
graduation_group_id: assign_group.id, user_id: assign_user_id, graduation_task_id: task.id)
count += 1
end
end
end
end
end
end end
task.update_attributes(status: 3) task.update_attributes(status: 3)
# 给老师发消息
tid_str = "" tid_str = ""
task.course.teachers.find_each do |member| task.course.teachers.find_each do |member|
tid_str += "," if tid_str != "" tid_str += "," if tid_str != ""

@ -23,59 +23,11 @@ namespace :homework_evaluation do
else else
student_works = homework_common.student_works.has_committed student_works = homework_common.student_works.has_committed
end end
if student_works.present? && student_works.length >= 2
if homework_common.homework_type == "group"
student_work_projects = homework_common.student_works.where("work_status != 0").shuffle
student_work_projects.each_with_index do |pro_work, pro_index|
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
work_index = -1
student_works.each_with_index do |stu_work, stu_index|
if stu_work.group_id.to_i == pro_work.group_id.to_i
work_index = stu_index
end
end
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
#更新CourseHomeworkStatistics中该学生的待匿评数 if student_works.present? && student_works.length >= 2
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, pro_work.user_id) HomeworkEvaluationCommentAssginJob.perform_later(homework_common.id)
# course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
end
else
student_works = student_works.shuffle
student_works.each_with_index do |work, index|
user = work.user
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
#更新CourseHomeworkStatistics中该学生的待匿评数
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, user.id)
# course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
end
end
homework_detail_manual.update_column('comment_status', 3) homework_detail_manual.update_column('comment_status', 3)
# 匿评开启消息邮件通知,# 所有人
str = ""
homework_common.course.course_members.pluck(:user_id).uniq.each do |user_id|
str += "," if str != ""
str += "('#{user_id}', '#{homework_common.user_id}', '#{homework_common.id}','HomeworkCommon','#{homework_common.id}',
'AnonymousComment',#{homework_common.course_id},'Course',0,'HomeworkCommon',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
else else
#作业数小于2启动失败, 只给老师和助教发 #作业数小于2启动失败, 只给老师和助教发
extra = "作品数量低于两个,无法开启匿评" extra = "作品数量低于两个,无法开启匿评"
@ -83,20 +35,8 @@ namespace :homework_evaluation do
else else
extra = "存在尚未截止的分班,无法开启匿评" extra = "存在尚未截止的分班,无法开启匿评"
end end
HomeworkEvaluationStartNotifyJob.perform_later(homework_common.id, extra)
if extra.present? if extra.present?
str = ''
homework_common.course.teachers.each do |mem|
str += "," if str != ""
str += "('#{mem.user.id}', '#{homework_common.user_id}', '#{homework_common.id}','HomeworkCommon','#{homework_common.id}',
'AnonymousCommentFail',#{homework_common.course_id},'Course',0,'System','#{extra}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type,parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, extra, created_at,
updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
homework_detail_manual.update_attributes(:evaluation_start => nil, :evaluation_end => nil, :absence_penalty => 0, homework_detail_manual.update_attributes(:evaluation_start => nil, :evaluation_end => nil, :absence_penalty => 0,
:evaluation_num => 0, :appeal_time => nil, :appeal_penalty => 0) :evaluation_num => 0, :appeal_time => nil, :appeal_penalty => 0)
homework_common.update_attributes(:anonymous_comment => 0, :anonymous_appeal => 0) homework_common.update_attributes(:anonymous_comment => 0, :anonymous_appeal => 0)
@ -114,63 +54,15 @@ namespace :homework_evaluation do
homework_detail_manuals.each do |homework_detail_manual| homework_detail_manuals.each do |homework_detail_manual|
homework_common = homework_detail_manual.homework_common homework_common = homework_detail_manual.homework_common
if homework_common.anonymous_comment #开启匿评状态才可关闭匿评 if homework_common.anonymous_comment #开启匿评状态才可关闭匿评
#计算缺评扣分 参与匿评
work_ids = "(" + homework_common.student_works.has_committed.map(&:id).join(",") + ")"
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 IN #{work_ids}").count -
student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
# absence_penalty_count = absence_penalty_count > 0 ? absence_penalty_count : 0
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, student_work.user_id)
# course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 :
# (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics
# course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics
end
# 未参与匿评
if homework_common.homework_detail_manual.no_anon_penalty == 0
all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}")
has_sw_count = all_dis_eva.select("distinct user_id").count
anon_count = all_dis_eva.count / has_sw_count
homework_common.student_works.where("work_status != 0").each do |student_work|
if student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count == 0
student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count
student_work.save
end
end
end
if homework_common.anonymous_appeal if homework_common.anonymous_appeal
homework_detail_manual.update_column('comment_status', 4) homework_detail_manual.update_column('comment_status', 4)
# 申诉开启 # 申诉开启发送消息
eva_distribution = StudentWorksEvaluationDistribution.where(:student_work_id => homework_common.student_works.pluck(:id)) HomeworkAnonymousAppealStartNotifyJob.perform_later(homework_common.id)
str = ""
eva_distribution.pluck(:user_id).uniq.each do |user_id|
str += "," if str != ""
str += "(#{user_id}, #{homework_common.user_id}, #{homework_common.id}, 'HomeworkCommon', #{homework_common.id},
'AnonymousAppeal', #{homework_common.course_id}, 'Course', 0, 'HomeworkCommon',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
else else
homework_detail_manual.update_column('comment_status', 5) homework_detail_manual.update_column('comment_status', 5)
end end
# 匿评关闭消息通知 给所有人发
# course = homework_common.course HomeworkAbsencePenaltyCalculationJob.perform_later(homework_common.id)
# course.members.each do |m|
# homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3)
# end
# 邮件通知
# Mailer.send_mail_anonymous_comment_close(homework_common).deliver
end end
end end
end end

@ -21,37 +21,31 @@ namespace :homework_publishtime do
homework_commons.each do |homework| homework_commons.each do |homework|
homework_detail_manual = homework.homework_detail_manual homework_detail_manual = homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 1) homework_detail_manual.update_column('comment_status', 1)
course = homework.course # 统一设置的作业在这发消息,非统一设置的只给有全部分班权限的老师发
students = course.students if homework.unified_setting
if !course.nil? && !students.empty? HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, nil)
else
course = homework.course
teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id))
tid_str = "" tid_str = ""
course.teachers.find_each do |member| teachers.find_each do |member|
tid_str += "," if tid_str != "" tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish', tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish',
#{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', #{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
if homework.unified_setting
students.each do |student|
tid_str += "," if tid_str != ""
tid_str += "(#{student.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id},
'HomeworkPublish', #{course.id}, 'Course', 0, 'HomeworkCommon',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
HomeworkPublishUpdateWorkStatusJob.perform_now(nil, homework.id)
end
if tid_str != "" if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at,
updated_at) values" + tid_str updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql ActiveRecord::Base.connection.execute tid_sql
end end
end
if homework.course_acts.size == 0
homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
end end
homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) if !homework.course_acts.exists?
end end
# 分组设置发布时间的作业 # 分组设置发布时间的作业
@ -59,27 +53,8 @@ namespace :homework_publishtime do
homework_group_settings.each do |homework_group| homework_group_settings.each do |homework_group|
homework = homework_group.homework_common homework = homework_group.homework_common
if homework.present? if homework.present?
course = homework.course
homework_detail_manual = homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 1) if homework_detail_manual.comment_status == 0
tid_str = ""
members = course.students.where(:course_group_id => homework_group.course_group_id)
members.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish',
#{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at,
updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql
end
HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.course_group_id])
end end
end end
Rails.logger.info("log--------------------------------homework_publish end") Rails.logger.info("log--------------------------------homework_publish end")
@ -98,11 +73,10 @@ namespace :homework_publishtime do
student_works = homework.student_works.where("work_status != 0") student_works = homework.student_works.where("work_status != 0")
# none_student_works = homework.student_works.where("work_status = 0") # none_student_works = homework.student_works.where("work_status = 0")
else else
setting = homework.homework_group_settings.where(:end_time => homework.end_time) setting = homework.homework_group_settings.where(end_time: homework.end_time)
unless setting.blank? unless setting.blank?
users = homework.course.students.where(:course_group_id => setting.map(&:course_group_id)) users = homework.course.students.where(course_group_id: setting.pluck(:course_group_id))
user_ids = users.blank? ? "(-1)" : "(" + users.map(&:user_id).join(",") + ")" student_works = homework.student_works.where("work_status != 0").where(user_id: users.pluck(:user_id))
student_works = homework.student_works.where("work_status != 0 and user_id in #{user_ids}")
# none_student_works = homework.student_works.where("work_status = 0 and user_id in #{user_ids}") # none_student_works = homework.student_works.where("work_status = 0 and user_id in #{user_ids}")
end end
end end
@ -172,8 +146,7 @@ namespace :homework_publishtime do
# homework_challenge_settings = homework.homework_challenge_settings # homework_challenge_settings = homework.homework_challenge_settings
users = homework.course.students.where(:course_group_id => homework_setting.course_group_id) users = homework.course.students.where(:course_group_id => homework_setting.course_group_id)
user_ids = users.blank? ? "(-1)" : "(" + users.map(&:user_id).join(",") + ")" student_works = homework.student_works.where("work_status != 0").where(user_id: users.pluck(:user_id))
student_works = homework.student_works.where("work_status != 0 and user_id in #{user_ids}")
student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if student_works.present? student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if student_works.present?
else else
# HomeworksService.new.update_student_eff_score homework # 分班设置的不需要另外算效率分 # HomeworksService.new.update_student_eff_score homework # 分班设置的不需要另外算效率分

@ -9,39 +9,22 @@ namespace :poll_publish do
polls = Poll.includes(:poll_users).where("publish_time is not null and polls_status = 1 and publish_time <=?",Time.now) polls = Poll.includes(:poll_users).where("publish_time is not null and polls_status = 1 and publish_time <=?",Time.now)
polls.each do |poll| polls.each do |poll|
poll.update_attributes(:polls_status => 2) poll.update_attributes(:polls_status => 2)
course = poll.course
tid_str = ""
course.teachers.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if poll.unified_setting if poll.unified_setting
course.students.find_each do |student| PollPublishNotifyJob.perform_later(poll.id, nil)
else
course = poll.course
teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id))
tid_str = ""
teachers.find_each do |member|
tid_str += "," if tid_str != "" tid_str += "," if tid_str != ""
tid_str += "(#{student.user_id}, #{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" tid_str += "(#{member.user_id}, #{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
end
if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql
end
if poll.poll_users.count == 0
str = ""
course.students.find_each do |student|
str += "," if str != ""
str += "(#{student.user_id},#{poll.id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
if tid_str != ""
if str != "" tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str
sql = "insert into poll_users (user_id, poll_id, commit_status, created_at, updated_at) values" + str ActiveRecord::Base.connection.execute tid_sql
ActiveRecord::Base.connection.execute sql
end end
end end
poll.course_acts << CourseActivity.new(user_id: poll.user_id, course_id: poll.course_id) if !poll.course_acts.exists?
if poll.course_acts.size == 0
poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id)
end
end end
# 分组设置发布时间的问卷 # 分组设置发布时间的问卷
@ -49,19 +32,8 @@ namespace :poll_publish do
poll_group_settings.each do |poll_group| poll_group_settings.each do |poll_group|
poll = poll_group.poll poll = poll_group.poll
if poll.present? if poll.present?
course = poll.course
poll.update_attributes(:polls_status => 2) if poll.polls_status == 1 poll.update_attributes(:polls_status => 2) if poll.polls_status == 1
PollPublishNotifyJob.perform_later(poll.id, [poll_group.course_group_id])
tid_str = ""
members = course.course_members.where(:course_group_id => poll_group.course_group_id)
members.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id},#{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql
end
end end
end end

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

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

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

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

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

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