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

dev_forum
cxt 6 years ago
commit 83446c1b5c

@ -1163,8 +1163,8 @@ class CoursesController < ApplicationController
course_id = course.id
course_name = course.name
course_list_name = course.course_list.present? ? course.course_list.name : "--"
course_assistants = course.course_members.course_user_role(%i[PROFESSOR ASSISTANT_PROFESSOR])
course_assistants_count = course_assistants&.count
course_assistants = course.teachers
course_assistants_count = course_assistants&.size
course_assistants_name = course_assistants_count > 0 ? course_assistants.map{|m| m.user.real_name}.join('、') : "--"
course_teacher_member = course.course_members.course_user_role(%i[CREATOR])
course_teacher = course_teacher_member.present? ? course_teacher_member.first.user.real_name : "--"
@ -1180,15 +1180,27 @@ class CoursesController < ApplicationController
course_main_info = [course_1,course_2,course_3,course_4,course_5,course_6,course_7]
course_group_info_head = %w(序号 分班名称 邀请码 学生数量)
course_group_info_body = []
if course.course_groups.present?
none_group_counts = course.none_group_count
#当有未分班时,应该也做个统计
if none_group_counts > 0
none_group_index = 2
no_group_array = [1,"未分班",course.invite_code,none_group_counts]
course_group_info_body.push(no_group_array)
else
none_group_index = 1
end
if course.course_groups.exists?
course.course_groups.each_with_index do |group, index|
group_index = (index+1)
group_index = (index+none_group_index)
group_name = group.name
group_code = group.invite_code
group_count = group.course_members_count
group_array = [group_index,group_name,group_code,group_count]
course_group_info_body.push(group_array)
end
end
course_group_info = [course_group_info_head,course_group_info_body]
@course_info += [course_info_title,course_main_info,course_group_info]
@ -1256,7 +1268,7 @@ class CoursesController < ApplicationController
#实训作业
if shixun_homeworks.size > 0
shixun_homeworks.each do |s|
shixun_homeworks&.includes(:score_student_works).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
@ -1272,7 +1284,7 @@ class CoursesController < ApplicationController
#普通作业
if common_homeworks.size > 0
common_homeworks.each do |c|
common_homeworks&.includes(:score_student_works).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
@ -1288,7 +1300,7 @@ class CoursesController < ApplicationController
#分组作业
if group_homeworks.size > 0
group_homeworks.each do |g|
group_homeworks&.includes(:score_student_works).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
@ -1304,7 +1316,7 @@ class CoursesController < ApplicationController
#毕设作业
if tasks.size > 0
tasks.each do |task|
tasks&.includes(:score_graduation_works).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
@ -1320,7 +1332,7 @@ class CoursesController < ApplicationController
#试卷
if exercises.size > 0
exercises.each do |ex|
exercises&.includes(:score_exercise_users).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
@ -1363,7 +1375,7 @@ class CoursesController < ApplicationController
count_4 = tasks.size
count_5 = exercises.size
#实训作业
shixun_homeworks.each_with_index do |s,index|
shixun_homeworks&.includes(:score_student_works).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)
@ -1373,7 +1385,7 @@ class CoursesController < ApplicationController
end
#普通作业
common_homeworks.each_with_index do |c,index|
common_homeworks&.includes(:score_student_works).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)
@ -1385,7 +1397,7 @@ class CoursesController < ApplicationController
end
#分组作业
group_homeworks.each_with_index do |c,index|
group_homeworks&.includes(:score_student_works).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)
@ -1395,23 +1407,21 @@ class CoursesController < ApplicationController
end
#毕设任务
tasks.each_with_index do |c,index|
tasks&.includes(:score_graduation_works).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)
work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
# work_content = [work_name,@work_head_cells,@work_cells_column]
work_content = [work_name,@head_cells_column,@task_cells_column]
@task_work_arrays.push(work_content)
end
#试卷的导出
exercises.each_with_index do |c,index|
exercises&.includes(:score_exercise_users).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)
work_name = format_sheet_name (title_no.to_s + "." + c.exercise_name).strip.first(30)
# work_content = [work_name,@work_head_cells,@work_cells_column]
work_content = [work_name,@table_columns,@user_columns]
@exercise_work_arrays.push(work_content)
end

@ -511,6 +511,8 @@ class GamesController < ApplicationController
GitService.delete_repository(repo_path: @myshixun.repo_path)
rescue Exception => e
uid_logger_error("#{e.message}")
# 终端循环
tip_exception("#{e.message}")
end
# fork一个新的仓库
# project_fork(@myshixun, @shixun.repo_path, current_user.login)
@ -705,10 +707,10 @@ class GamesController < ApplicationController
resubmit_identifier = @game.resubmit_identifier
# 如果没有超时并且正在评测中
# 判断评测中的状态有两种1、如果之前没有通关的只需判断status为1即可如果通过关则判断game的resubmit_identifier是否更新
# uid_logger("################game_status: #{@game.status}")
# uid_logger("################params[:resubmit]: #{params[:resubmit]}")
# uid_logger("################resubmit_identifier: #{resubmit_identifier}")
# uid_logger("################time_out: #{params[:time_out]}")
uid_logger("################game_status: #{@game.status}")
uid_logger("################params[:resubmit]: #{params[:resubmit]}")
uid_logger("################resubmit_identifier: #{resubmit_identifier}")
uid_logger("################time_out: #{params[:time_out]}")
if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? &&
(params[:resubmit] != resubmit_identifier)))
# 代码评测的信息

@ -97,9 +97,8 @@ class MyshixunsController < ApplicationController
game_id = jsonTestDetails['buildID']
sec_key = jsonTestDetails['sec_key']
# 资源消耗
res_usage = jsonTestDetails['resUsage']
# 关卡测试集的总耗时
ts_time = 0
logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
resubmit = jsonTestDetails['resubmit']
@ -124,7 +123,7 @@ class MyshixunsController < ApplicationController
jenkins_testsets.each_with_index do |j_test_set, i|
logger.info("j_test_set: ############## #{j_test_set}")
actual_output = tran_base64_decode64(j_test_set['output'])
ts_time += j_test_set['testSetTime'].to_i
#ts_time += j_test_set['testSetTime'].to_i
# is_public = test_sets.where(:position => j_test_set['caseId']).first.try(:is_public)
logger.info "actual_output:################################################# #{actual_output}"
@ -138,7 +137,6 @@ class MyshixunsController < ApplicationController
end
end
uid_logger("#############status: #{status}")
uid_logger("#############resubmit: #{resubmit}")
record = EvaluateRecord.where(:game_id => game_id).first
logger.info("training_task_status start#3**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
answer_deduction_percentage = (100 - game.answer_deduction) / 100.to_f # 查看答案后剩余分数的百分比.
@ -146,6 +144,7 @@ class MyshixunsController < ApplicationController
# status0表示评测成功
if status == "0"
if resubmit.present?
uid_logger("#############resubmitdaiao: #{resubmit}")
game.update_attributes!(:retry_status => 2, :resubmit_identifier => resubmit)
challenge.path.split("").each do |path|
game_passed_code(path.try(:strip), myshixun, game_id)
@ -199,7 +198,7 @@ class MyshixunsController < ApplicationController
if record.present?
consume_time = format("%.3f", (Time.now - record.created_at)).to_f
record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'],
:pod_execute => timeCost['execute'], :test_cases => test_cases_time, :ts_time => ts_time,
:pod_execute => timeCost['execute'], :test_cases => test_cases_time,
:brige => timeCost['evaluateAllTime'], :return_back => return_back_time)
end
uid_logger("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")

@ -88,8 +88,8 @@ module ExercisesHelper
question_infos = []
percent = 0.0
questions.includes(:exercise_choices).each do |ex|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
ex_answers = ex.exercise_answers
ex_total_score = user_ids.count * ex&.question_score.to_f #该试卷的已回答的总分
# ex_answers = ex.exercise_answers
if ex.question_type != Exercise::PRACTICAL
ques_title = ex.question_title
ques_less_title = nil
@ -98,23 +98,23 @@ module ExercisesHelper
else
ques_title = ex.shixun.name
ques_less_title = ex.question_title
effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids)
ex_answers = ex.exercise_shixun_answers
effictive_users = ex_answers.search_shixun_answers("user_id",user_ids)
end
effictive_users_count = effictive_users.size #有效回答数可能有重复的用户id这里仅统计是否回答这个问题的全部人数
ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分
if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时,
if ex_total_score != 0.0
percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率
end
percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率
end
question_answer_infos = []
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
ex_choices = ex.exercise_choices
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置
right_users_count = 0 #该问题的回答正确的人数
right_users_count = 0
#该问题的正确率
if ex.question_type == Exercise::MULTIPLE #多选题
user_ids.each do |user_id|
ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq
@ -129,15 +129,14 @@ module ExercisesHelper
end
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
#每个选项的正确率
ex_choices.each do |c|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id)
answer_users_count = answer_this_choice.size
if effictive_users_count == 0
answer_percent = 0.0
else
answer_percent = (answer_users_count / effictive_users_count.to_f ).round(3)
end
answer_users_count = effictive_users.select{|answer| answer.exercise_choice_id == c.id}.size
answer_percent = (effictive_users_count == 0 ? 0.0 : (answer_users_count / effictive_users_count.to_f ).round(3))
answer_option = {
:choice_position => c.choice_position,
:choice_text => c.choice_text,
@ -150,7 +149,7 @@ module ExercisesHelper
elsif ex.question_type == Exercise::COMPLETION #填空题
ex_ordered = ex.is_ordered
null_standard_answer = ex.exercise_standard_answers
null_stand_choice = null_standard_answer.pluck(:exercise_choice_id)
null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text
null_stand_text = null_standard_answer.pluck(:answer_text)
standard_answer_count = 0
all_user_count = 0
@ -159,20 +158,17 @@ module ExercisesHelper
s_choice_text = null_stand_text[index]
if ex_ordered #有序排列
user_ids.each do |u|
user_answers = ex_answers.search_answer_users("user_id",u).search_answer_users("exercise_choice_id",s)
user_answers_choice = user_answers.present? ? user_answers.first.answer_text : ""
user_answers = ex_answers.where(user_id:u,exercise_choice_id:s).select(:answer_text)
user_answers_choice = user_answers.exists? ? user_answers&.first&.answer_text.to_s : ""
if s_choice_text == user_answers_choice
user_count += 1
end
end
else
user_count = user_count + effictive_users.search_exercise_answer("answer_text",s_choice_text).count #回答了标准答案的用户
end
if effictive_users_count == 0
answer_percent = 0.0
else
answer_percent = (user_count / effictive_users_count.to_f ).round(3)
user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户
end
answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3))
answer_option = {
:choice_position => index+1,
:choice_text => s_choice_text,
@ -237,22 +233,13 @@ module ExercisesHelper
all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).size #零分人数
shixun_scores = user_ids.count * cha_score
shixun_answered_scores = cha_shixun_answer.score_reviewed.pluck(:score).sum #该问题的全部得分
if shixun_answered_scores == 0.0
game_percent = 0.0
else
game_percent = (shixun_answered_scores / shixun_scores.to_f).round(3) * 100 #正确率
end
game_percent = (shixun_answered_scores == 0.0 ? 0.0 : (shixun_answered_scores / shixun_scores.to_f).round(3) * 100) #正确率
shixun_score_array = [full_scores,no_full_scores,all_zero_scores]
shixun_chas = []
shixun_score_array.each_with_index do |s,index|
right_answer = (index == 0)
if effictive_users_count == 0
score_percent = 0.0
else
score_percent = (s.to_i / effictive_users_count.to_f ).round(3)
end
score_percent = (effictive_users_count == 0 ? 0.0 : (s.to_i / effictive_users_count.to_f ).round(3))
answer_option = {
:choice_position => index+1,
:choice_text => index+1,

@ -41,9 +41,9 @@ module ExportHelper
w_user = w.user
w_1 = (index + 1)
if w_user.present?
w_2 = w_user&.login
w_3 = w_user&.real_name
w_3_1 = w_user&.mail
w_2 = w_user&.login.present? ? w_user&.login : "--"
w_3 = w_user&.real_name.present? ? w_user&.real_name : "--"
w_3_1 = w_user&.mail.present? ? w_user.mail : "--"
w_4 = w_user.student_id.present? ? w_user.student_id : "--"
else
w_2 = "--"
@ -129,9 +129,9 @@ module ExportHelper
myshixun = w.try(:myshixun)
w_user = w.user
w_1 = (index + 1)
w_2 = w_user.login
w_3 = w_user.real_name
w_3_1 = w_user.mail
w_2 = w_user&.login.present? ? w_user&.login : "--"
w_3 = w_user&.real_name.present? ? w_user&.real_name : "--"
w_3_1 = w_user&.mail.present? ? w_user.mail : "--"
w_4 = w_user.student_id.present? ? w_user.student_id : "--"
course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--"
@ -163,7 +163,7 @@ module ExportHelper
end
w_15 = w.work_score.nil? ? "--" : w.work_score.round(1)
w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间"
w_17 = w.cost_time
w_17 = (game_spend_time w.cost_time)
teacher_comments = w.student_works_scores
if teacher_comments.present?
w_18 = ""
@ -173,7 +173,6 @@ module ExportHelper
user_score = t&.score
user_comment = t.comment.present? ? t.comment : "--"
comment_title = "#{user_name} #{user_time.to_s} #{user_score.to_s}\n#{user_comment}\n\n"
# ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n")
w_18 = w_18 + comment_title
end
else
@ -214,9 +213,9 @@ module ExportHelper
items.includes(user: :user_extension).each_with_index do |work,index|
w_1 = (index+1)
w_user = work.user
w_2 = w_user.login
w_3 = w_user.real_name
w_3_1 = w_user.mail
w_2 = w_user&.login.present? ? w_user&.login : "--"
w_3 = w_user&.real_name.present? ? w_user&.real_name : "--"
w_3_1 = w_user&.mail.present? ? w_user.mail : "--"
w_4 = w_user.student_id.present? ? w_user.student_id : "--"
w_5 = work.class_grouping_name
if task_type_boolean #是否分组
@ -305,8 +304,11 @@ module ExportHelper
user_start_time = e_user.start_at.present? ? e_user.start_at.strftime('%Y-%m-%d %H:%M') : "--"
user_end_time = e_user.end_at.present? ? e_user.end_at.strftime('%Y-%m-%d %H:%M') : "--"
user_student_id = user_info.student_id.present? ? user_info.student_id : "--"
user_login = user_info&.login.present? ? user_info.login : "--"
user_real_name = user_info.real_name.present? ? user_info.real_name : "--"
user_mail = user_info&.mail.present? ? user_info.mail : "--"
user_option = [index+1,user_info.login,user_info.real_name, user_info.mail || '--',
user_option = [index+1,user_login,user_real_name, user_mail,
user_student_id,user_course,user_commit_stu]
if ques_type_boolean
other_user_option = [user_obj_score,user_suj_score,user_score,user_start_time,user_end_time]
@ -335,11 +337,11 @@ module ExportHelper
topic = nil
end
w_1 = (index+1)
w_2 = user.login
w_3 = user.real_name
w_3_1 = user.mail
w_4 = user.student_id
w_5 = student.course_group_name
w_2 = user&.login.present? ? user&.login : "--"
w_3 = user&.real_name.present? ? user&.real_name : "--"
w_3_1 = user&.mail.present? ? user.mail : "--"
w_4 = user.student_id.present? ? user.student_id : "--"
w_5 = student&.course_group_name.present? ? student.course_group_name : "--"
w_6 = topic.present? ? topic.name : "--"
w_7 = topic.present? ? topic.teacher.full_name : "--"
w_8 = topic.present? ? topic.teacher.identity : "--"

@ -103,7 +103,7 @@ class Course < ApplicationRecord
# 未分班的学生数
def none_group_count
course_members.where(role: 4, course_group_id: 0).count
course_members.where(role: 4, course_group_id: 0).size
end
def course_member(user_id)

@ -22,7 +22,7 @@ index = 1
json.game_list @myshixun.games do |game|
json.position index
json.end_time game.end_time ? game.end_time : '--'
json.cost_time game.cost_time
json.cost_time (game_spend_time game.cost_time)
json.score game.final_score
json.complete_status game_status(game, @homework)
index += 1

@ -13,7 +13,7 @@ module Educoder
@status = status
@message = message
Rails.logger.info("############# #{@status}, #{@message}")
Rails.logger.error("############# #{@status}, #{@message}")
end
def tip_json

Loading…
Cancel
Save