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

dev_forum
jingquan huang 6 years ago
commit 82a2401795

@ -1139,21 +1139,21 @@ class CoursesController < ApplicationController
#课堂的作业信息
shixun_homeworks = homeworks.search_homework_type(4) #全部实训作业
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
shixun_homeworks = shixun_homeworks.includes(:score_student_works)
shixun_homeworks = shixun_homeworks&.includes(score_student_works: :user)
common_homeworks = homeworks.search_homework_type(1) #全部普通作业
common_titles = common_homeworks.pluck(:name)+ ["总得分"]
common_homeworks = common_homeworks.includes(:score_student_works)
common_homeworks = common_homeworks&.includes(score_student_works: :user)
group_homeworks = homeworks.search_homework_type(3) #全部分组作业
group_titles = group_homeworks.pluck(:name)+ ["总得分"]
group_homeworks = group_homeworks.includes(:score_student_works)
group_homeworks = group_homeworks&.includes(score_student_works: :user)
task_titles = tasks.pluck(:name) + ["总得分"]
tasks = tasks.includes(:score_graduation_works)
tasks = tasks&.includes(user: :user_extension, score_graduation_works: :user)
exercise_titles = exercises.pluck(:exercise_name) + ["总得分"]
exercises = exercises.includes(:score_exercise_users)
exercises = exercises&.includes(user: :user_extension, score_exercise_users: :user)
total_user_score_array = [] #学生总成绩集合
@ -1268,7 +1268,7 @@ class CoursesController < ApplicationController
#实训作业
if shixun_homeworks.size > 0
shixun_homeworks&.includes(:score_student_works).each do |s|
shixun_homeworks.each do |s|
user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work.nil?
h_score = 0.0 #该作业的得分为0
@ -1284,7 +1284,7 @@ class CoursesController < ApplicationController
#普通作业
if common_homeworks.size > 0
common_homeworks&.includes(:score_student_works).each do |c|
common_homeworks.each do |c|
user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_1.nil?
h_score_1 = 0.0 #该作业的得分为0
@ -1300,7 +1300,7 @@ class CoursesController < ApplicationController
#分组作业
if group_homeworks.size > 0
group_homeworks&.includes(:score_student_works).each do |g|
group_homeworks.each do |g|
user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_3.nil?
h_score_3 = 0.0 #该作业的得分为0
@ -1316,7 +1316,7 @@ class CoursesController < ApplicationController
#毕设作业
if tasks.size > 0
tasks&.includes(:score_graduation_works).each do |task|
tasks.each do |task|
graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first
if graduation_work.nil?
t_score = 0.0
@ -1332,7 +1332,7 @@ class CoursesController < ApplicationController
#试卷
if exercises.size > 0
exercises&.includes(:score_exercise_users).each do |ex|
exercises.each do |ex|
exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first
if exercise_work.nil?
e_score = 0.0
@ -1375,7 +1375,7 @@ class CoursesController < ApplicationController
count_4 = tasks.size
count_5 = exercises.size
#实训作业
shixun_homeworks&.includes(:score_student_works).each_with_index do |s,index|
shixun_homeworks.each_with_index do |s,index|
all_student_works = s.score_student_works #该实训题的全部用户回答
title_no = index.to_i + 1
student_work_to_xlsx(all_student_works,s)
@ -1385,7 +1385,7 @@ class CoursesController < ApplicationController
end
#普通作业
common_homeworks&.includes(:score_student_works).each_with_index do |c,index|
common_homeworks.each_with_index do |c,index|
all_student_works = c.score_student_works #当前用户的对该作业的回答
title_no = count_1 + index.to_i + 1
student_work_to_xlsx(all_student_works,c)
@ -1397,7 +1397,7 @@ class CoursesController < ApplicationController
end
#分组作业
group_homeworks&.includes(:score_student_works).each_with_index do |c,index|
group_homeworks.each_with_index do |c,index|
all_student_works = c.score_student_works #当前用户的对该作业的回答
title_no = count_1 + count_2 + index.to_i + 1
student_work_to_xlsx(all_student_works,c)
@ -1407,7 +1407,7 @@ class CoursesController < ApplicationController
end
#毕设任务
tasks&.includes(:score_graduation_works).each_with_index do |c,index|
tasks.each_with_index do |c,index|
all_student_works = c.score_graduation_works #当前用户的对该作业的回答
title_no = count_1 + count_2 + count_3 + index.to_i + 1
graduation_work_to_xlsx(all_student_works,c,current_user)
@ -1417,7 +1417,7 @@ class CoursesController < ApplicationController
end
#试卷的导出
exercises&.includes(:score_exercise_users).each_with_index do |c,index|
exercises.each_with_index do |c,index|
all_student_works = c.score_exercise_users #当前用户的对该作业的回答
title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1
get_export_users(c,course,all_student_works)

@ -35,6 +35,9 @@ class MyshixunsController < ApplicationController
StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0)
# 实训在申请发布前,是否玩过实训,如果玩过需要更改记录,防止二次重置
shixun_mod = ShixunModify.exists?(:shixun_id => @shixun.id, :myshixun_id => @myshixun.id, :status => 1)
shixun_mod.update_column(:status, 0) if shixun_mod
rescue Exception => e
uid_logger_error("myshixun reset failed #{e}")
raise ActiveRecord::Rollback

@ -513,7 +513,7 @@ class ShixunsController < ApplicationController
# 中间需要一个过渡动画
# TODO: 第一次开启实训都会去判断是否是纯选择题类型,感觉做成在创建关卡的时候就判断该实训是否是纯选择题更加合适
def shixun_exec
if @shixun.opening_time.present? && @shixun.opening_time > Time.now && current_user.shixun_identity(@shixun) > User::EDU_SHIXUN_MEMBER
if is_shixun_opening?
tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}")
end
current_myshixun = @shixun.current_myshixun(current_user.id)
@ -522,8 +522,8 @@ class ShixunsController < ApplicationController
if current_myshixun
games = current_myshixun.games
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置
if games.size != min_challenges.size || games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first}
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置,实训发布前打过的实训都需要重置
if is_shixun_reset?(games, min_challenges, current_myshixun)
# 这里页面弹框要收到 当前用户myshixun的identifier.
tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game")
end
@ -745,6 +745,7 @@ class ShixunsController < ApplicationController
# 撤销发布
def cancel_publish
tip_exception("实训已经发布,无法撤销") if @shixun.status == 2
apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
if apply && apply.status == 0
apply.update_attribute(:status, 3)
@ -802,4 +803,20 @@ private
tip_exception(403, "..")
end
end
# 实训是否需要开启
def is_shixun_opening?
@shixun.opening_time.present? &&
@shixun.opening_time > Time.now &&
current_user.shixun_identity(@shixun) > User::EDU_SHIXUN_MEMBER
end
# 实训是否需要重置
def is_shixun_reset?(games, min_challenges, current_myshixun)
# 用户在申请发布之前,是否玩过实训
modify_shixun = ShixunModify.exists?(:myshixun_id => current_myshixun.id, :shixun_id => @shixun.id, :status => 1)
games.size != min_challenges.size ||
games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first} ||
modify_shixun
end
end

@ -1,8 +1,9 @@
class Users::InterestsController < Users::BaseController
skip_before_action :check_observed_user_exists!
before_action :require_login, :check_auth
before_action :require_login
def create
return render_forbidden if current_user.user_extension&.identity.present?
identity = params[:identity].to_s.strip
extension = current_user.user_extension || current_user.build_user_extension

@ -69,7 +69,7 @@ class Game < ApplicationRecord
else
if self.status == 2
gold = (shixun_status <= 1) ? 0 : self.final_score.to_i
experience = (shixun_status <= 1 || self.final_score.to_i < 0) ? 0 : challenge.score.to_i
experience = (shixun_status <= 1 || self.final_score.to_i < 0) ? 0 : challenge.choose_score.to_i
else
# 选择题只有在全对的时候才会获取final score总分错任何一个题final_score就为0
gold = challenge.choose_score

@ -13,7 +13,7 @@ if @challenges.present?
json.position challenge.position
json.st challenge.st
json.name challenge.subject
json.score challenge.score
json.score challenge.all_score
json.passed_count challenge.user_passed_count
json.playing_count challenge.playing_count
json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)

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

@ -34,7 +34,7 @@ elsif @user_course_identity == Course::STUDENT
json.(@work, :id, :work_status, :update_time, :ultimate_score)
json.calculation_time @work.calculation_time
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_spend_time)
json.work_score work_score_format(@work.work_score, true, @score_open)
json.final_score work_score_format(@work.final_score, true, @score_open)
json.efficiency work_score_format(@work.efficiency, true, @score_open)
@ -91,7 +91,7 @@ if @homework.homework_type == "practice"
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, @score_open)
json.cost_time work.myshixun.try(:total_cost_time)
json.cost_time work.myshixun.try(:total_spend_time)
json.complete_count work.myshixun.try(:passed_count)
json.user_login work.user.try(:login)
json.user_name work.user.try(:real_name)

Loading…
Cancel
Save