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

dev_forum
jasder 5 years ago
commit 891597698c

@ -151,8 +151,8 @@ class ChallengesController < ApplicationController
def index def index
uid_logger("identifier: #{params}") uid_logger("identifier: #{params}")
# 通过调试发现 这里includes(:games)性能会慢10倍 # 通过调试发现 这里includes(:games)性能会慢10倍
current_myshixun = @shixun.current_myshixun(current_user.id)
@challenges = @shixun.challenges.fields_for_list.includes(:games).where("games.user_id" => current_user.id) @challenges = @shixun.challenges.includes(:games).where("games.user_id" => (current_myshixun ? current_user.id : nil))
@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

@ -9,6 +9,8 @@ module GitHelper
# 版本库文件内容,带转码 # 版本库文件内容,带转码
def git_fle_content(repo_path, path) def git_fle_content(repo_path, path)
begin begin
logger.info("##########repo_path: #{repo_path}")
logger.info("##########path: #{path}")
content = GitService.file_content(repo_path: repo_path, path: path) content = GitService.file_content(repo_path: repo_path, path: path)
logger.info("@@@@@@@@@@@@@@@@@@#{content}") logger.info("@@@@@@@@@@@@@@@@@@#{content}")
@ -31,7 +33,8 @@ module GitHelper
decode_content decode_content
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) Rails.logger.error(e.message)
# uid_logger_error(e.message)
raise Educoder::TipException.new("文档内容获取异常") raise Educoder::TipException.new("文档内容获取异常")
end end
end end

@ -799,6 +799,8 @@ class CoursesController < ApplicationController
uid_logger_error(e.message) uid_logger_error(e.message)
normal_status(-1, "无法完成导入,原因:文件内容无法读取") normal_status(-1, "无法完成导入,原因:文件内容无法读取")
end end
else
normal_status(-1, "只支持xls文件的导入")
end end
end end
end end

@ -616,7 +616,7 @@ class ExerciseQuestionsController < ApplicationController
elsif params[:question_type].to_i == 2 && (params[:standard_answers].count > 1 || params[:question_choices].blank? || params[:question_choices].include?("")) #判断题的标准答案不能大于1个选项不能为空 elsif params[:question_type].to_i == 2 && (params[:standard_answers].count > 1 || params[:question_choices].blank? || params[:question_choices].include?("")) #判断题的标准答案不能大于1个选项不能为空
normal_status(-1,"判断题选项不能为空/标准答案不能大于1个") normal_status(-1,"判断题选项不能为空/标准答案不能大于1个")
elsif params[:question_type].to_i <= 1 && (params[:question_choices].blank? || params[:question_choices].include?("") || params[:question_choices].count < 2) #选择题选项不能为空,且不能小于2 elsif params[:question_type].to_i <= 1 && (params[:question_choices].blank? || params[:question_choices].include?("") || params[:question_choices].count < 2) #选择题选项不能为空,且不能小于2
normal_status(-1,"选择题选项内容不能为空,且不能少于3个!") normal_status(-1,"选择题选项内容不能为空,且不能少于2个!")
elsif params[:question_type].to_i == 3 && (params[:standard_answers].blank? || params[:standard_answers].count > 5 ) #填空题选项最多为5个,且如果为1个的话不允许修改is_ordered elsif params[:question_type].to_i == 3 && (params[:standard_answers].blank? || params[:standard_answers].count > 5 ) #填空题选项最多为5个,且如果为1个的话不允许修改is_ordered
normal_status(-1,"填空题标准答案不能为空/不能超过5个") normal_status(-1,"填空题标准答案不能为空/不能超过5个")
elsif params[:question_type].to_i == 4 && params[:standard_answers].count > 2 #简单题参考答案最多为1个 elsif params[:question_type].to_i == 4 && params[:standard_answers].count > 2 #简单题参考答案最多为1个
@ -640,7 +640,7 @@ class ExerciseQuestionsController < ApplicationController
if @exercise.exercise_status != 1 if @exercise.exercise_status != 1
question_score = @exercise_question.question_score #原来的分数 question_score = @exercise_question.question_score #原来的分数
update_question_score = params[:question_score].to_f.round(1) #传入的分数 update_question_score = params[:question_score].to_f.round(1) #传入的分数
choices_count = @exercise_question.exercise_choices.count #原来的选项个数 choices_count = @exercise_question.exercise_choices.size #原来的选项个数
exercise_choice_ids = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).uniq exercise_choice_ids = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).uniq
standard_answers_text = @exercise_question.exercise_standard_answers.pluck(:answer_text).uniq standard_answers_text = @exercise_question.exercise_standard_answers.pluck(:answer_text).uniq
update_choices_count = params[:question_choices].present? ? params[:question_choices].count : choices_count #传入的选项个数 update_choices_count = params[:question_choices].present? ? params[:question_choices].count : choices_count #传入的选项个数

@ -1177,15 +1177,16 @@ class ExercisesController < ApplicationController
@exercise_status = @exercise.get_exercise_status(current_user.id) @exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students @course_all_members = @course.students
@c_group_counts = @course.course_groups_count @c_group_counts = @course.course_groups_count
question_types = @exercise.exercise_questions.pluck(:question_type) question_types = @exercise.exercise_questions.pluck(:question_type).uniq
@exercise_publish_count = get_user_permission_course(exercise_ids,2).count #判断是否有已发布的分班 @exercise_publish_count = get_user_permission_course(exercise_ids,2).count #判断是否有已发布的分班
@exercise_unpublish_count = get_user_permission_course(exercise_ids,1).count #判断是否有未发布的分班 @exercise_unpublish_count = get_user_permission_course(exercise_ids,1).count #判断是否有未发布的分班
if question_types.include?(4) #是否包含主观题 if (question_types.size > 1) && question_types.include?(4) #是否包含主观题,或者是否大于1
@subjective_type = 1 @subjective_type = 1
else else
@subjective_type = 0 @subjective_type = 0
end end
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的试卷 if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的试卷
@exercise_current_user_status = 0 @exercise_current_user_status = 0
if @exercise_status == 1 if @exercise_status == 1

@ -51,9 +51,8 @@ class GamesController < ApplicationController
# 统计评测时间 # 统计评测时间
record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:consume_time) record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:consume_time)
# power判断用户是否有权限查看隐藏测试集(TPM管理员平台认证的老师花费金币查看者) # myshixun_manager判断用户是否有权限查看隐藏测试集(TPM管理员平台认证的老师花费金币查看者)
# myshixun_manager myshixun_manager = @identity < User::EDU_GAME_MANAGER
myshixun_manager = current_user.manager_of_shixun?(@shixun) || (current_user.is_teacher? && current_user.pro_certification?)
# 选择题和编程题公共部分 # 选择题和编程题公共部分
@base_date = {st: @st, discusses_count: discusses_count, game_count: game_count, myshixun: @myshixun, @base_date = {st: @st, discusses_count: discusses_count, game_count: game_count, myshixun: @myshixun,

@ -122,7 +122,7 @@ class GraduationTasksController < ApplicationController
@work_count = @work_list.count @work_count = @work_list.count
@work_excel = @work_list @work_excel = @work_list
@work_list = @work_list.page(page).limit(limit) @work_list = @work_list.page(page).per(limit)
respond_to do |format| respond_to do |format|
format.json format.json
format.xlsx{ format.xlsx{

@ -235,6 +235,99 @@ class HomeworkCommonsController < ApplicationController
end end
end end
def update_score
student_works = @homework.student_works
myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id, user_id: @course.students.pluck(:user_id))
myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id).
joins("join course_members on myshixuns.user_id=course_members.user_id").where(course_members: {course_id: @course.id, role: 4}).includes(:games)
myshixuns.find_each(batch_size: 100) do |myshixun|
work = student_works.select{|work| work.user_id == myshixun.user_id}.first
setting_time = @homework.homework_group_setting work.user_id
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (@homework.allow_late && @homework.late_time && @homework.late_time > Time.now))
#logger.info("#############setting_time: #{setting_time.end_time}")
user_total_score = 0
pass_consume_time = 0
final_score = 0
homework.homework_challenge_settings.each do |setting|
game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first
unless game.nil?
pass_consume_time += (game.cost_time / 60.0).to_f
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last
final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0))
end
end
if work.work_status == 0
is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)
work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2)
work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty)
work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at
work.myshixun_id = myshixun.id
end
games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id))
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
if myshixun_endtime.present?
min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false
work.compelete_status = 1
work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
work.efficiency = format("%.2f", efficiency)
# 如果作业的最大效率值有变更则更新所有作品的效率分
if homework.work_efficiency && homework.max_efficiency < work.efficiency
homework.update_column("max_efficiency", work.efficiency)
end
end
work.update_time = Time.now
work.final_score = final_score
score = work.final_score + work.eff_score - work.late_penalty
work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score
#logger.info("#############work_score: #{score}")
work.save!
end
end
@homework.student_works.each do ||
end
end
def update_student_score
work = @homework.students_works.find_by(user_id: current_user.id)
myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id)
if work && myshixun
# 判断作品是否关联过myshixun
if work.myshixun_id.nil?
work.myshixun_id = myshixun.id
work.update_time = myshixun.updated_at
setting_time = @homework.homework_group_setting myshixun.user_id
games = myshixun.games.where(:challenge_id => @homework.homework_challenge_settings.pluck(:challenge_id))
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
compelete_status = 0
if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time
if myshixun_endtime < setting_time.publish_time
compelete_status = 2
else
compelete_status = 1
end
end
games.each do |game|
unless game.nil?
pass_consume_time += (game.cost_time / 60.0).to_f
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last
final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0))
end
end
end
end
end
def alter_name def alter_name
tip_exception("作业名称不能为空") if params[:name].blank? tip_exception("作业名称不能为空") if params[:name].blank?
@homework.update_attributes(name: params[:name].strip) @homework.update_attributes(name: params[:name].strip)
@ -620,7 +713,7 @@ class HomeworkCommonsController < ApplicationController
if @homework_detail_manual.comment_status < 4 if @homework_detail_manual.comment_status < 4
tip_exception("匿评结束时间不能为空") if @homework.anonymous_comment && params[:evaluation_end].blank? tip_exception("匿评结束时间不能为空") if @homework.anonymous_comment && params[:evaluation_end].blank?
tip_exception("匿评截止时间必须晚于匿评开启时间") if @homework.anonymous_comment && tip_exception("匿评截止时间必须晚于匿评开启时间") if @homework.anonymous_comment &&
params[:evaluation_end] <= params[:evaluation_start] params[:evaluation_end] <= strf_time(@homework_detail_manual.evaluation_start)
tip_exception("匿评截止时间不能晚于课堂结束时间") if @homework.anonymous_comment && tip_exception("匿评截止时间不能晚于课堂结束时间") if @homework.anonymous_comment &&
@course.end_date.present? && params[:evaluation_end] > strf_time(@course.end_date.end_of_day) @course.end_date.present? && params[:evaluation_end] > strf_time(@course.end_date.end_of_day)

@ -243,43 +243,39 @@ class MyshixunsController < ApplicationController
# -----Repository # -----Repository
# TODO: 之类需要一个resubmit参数,但是是关于games. # TODO: 之类需要一个resubmit参数,但是是关于games.
def update_file def update_file
begin
@hide_code = Shixun.where(id: @myshixun.shixun_id).pluck(:hide_code).first @hide_code = Shixun.where(id: @myshixun.shixun_id).pluck(:hide_code).first
tip_exception("技术平台为空!") if @myshixun.mirror_name.blank? tip_exception("技术平台为空!") if @myshixun.mirror_name.blank?
path = params[:path].strip unless params[:path].blank? path = params[:path].strip unless params[:path].blank?
game_id = params[:game_id] game_id = params[:game_id]
game = Game.find(game_id) game = Game.find(game_id)
@content_modified = 0 @content_modified = 0
# params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过 # params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过
# 自动保存的时候evaluate为0点评测的时候为1 # 自动保存的时候evaluate为0点评测的时候为1
if params[:evaluate] == 1 if params[:evaluate] == 1
record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun_id, :game_id => game_id) @sec_key = generate_identifier(EvaluateRecord, 12)
uid_logger("-- game is #{game_id}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun_id, :game_id => game_id,
student_work_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f :identifier => @sec_key)
record.update_attributes!(:student_work => student_work_time) uid_logger("-- game build: file update #{@sec_key}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
end end
unless @hide_code unless @hide_code
# 远程版本库文件内容 # 远程版本库文件内容
last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"]
content = params[:content]
content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present?
params[:content].gsub(/\t/, ' ')
else
params[:content]
end
if content != last_content if content != last_content
@content_modified = 1 @content_modified = 1
author_name = current_user.full_name author_name = current_user.full_name
author_email = current_user.mail author_email = current_user.mail
message = params[:evaluate] == 0 ? "auto commit" : "task commit" message = params[:evaluate] == 0 ? "System automatically submitted" : "User submitted"
@content = GitService.update_file(repo_path: @repo_path, @content = GitService.update_file(repo_path: @repo_path,
file_path: path, file_path: path,
message: message, message: message,
content: content, content: content,
author_name: author_name, author_name: author_name,
author_email: author_email) author_email: author_email)
uid_logger("-- file update #{@content}")
end end
end end
@ -293,6 +289,10 @@ class MyshixunsController < ApplicationController
consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f
record.update_attributes!(:file_update => consume_time) record.update_attributes!(:file_update => consume_time)
end end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("文件内容更新异常,请稍后重试")
end
end end
# 渲染实训代码 # 渲染实训代码

@ -553,11 +553,6 @@ class ShixunsController < ApplicationController
end end
end end
# REDO:开启实训时更新关联作品的状态
# TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做
# HomeworksService.new.update_myshixun_work_status myshixun
UpdateMyshixunWorkStatusJob.perform_later(myshixun.id)
@current_task = myshixun.current_task(myshixun.games) @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
@ -635,7 +630,7 @@ class ShixunsController < ApplicationController
end end
page = params[:page] || 1 page = params[:page] || 1
limit = params[:limit] || 20 limit = params[:limit] || 20
@users_count = @users.count @user_count = @users.count
@users = @users.page(page).per(limit) @users = @users.page(page).per(limit)
end end

@ -43,7 +43,7 @@ class StudentWorksController < ApplicationController
def search_member_list def search_member_list
# 统一设置的作业取所有学生,否则取已发布的分班学生 # 统一设置的作业取所有学生,否则取已发布的分班学生
students = @homework.unified_setting? ? @course.students : @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id)) students = @homework.unified_setting? ? @course.students : @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id))
unless params[:search].blank? if !params[:search].blank?
@members = students.joins(user: :user_extension).where("course_members.user_id != #{current_user.id} and (concat(users.lastname, users.firstname) @members = students.joins(user: :user_extension).where("course_members.user_id != #{current_user.id} and (concat(users.lastname, users.firstname)
like ? or user_extensions.student_id like ?)", "%#{params[:search]}%", "%#{params[:search]}%") like ? or user_extensions.student_id like ?)", "%#{params[:search]}%", "%#{params[:search]}%")
else else

@ -1,6 +1,7 @@
# 所有的方法请按首字母的顺序依次列出 # 所有的方法请按首字母的顺序依次列出
module ApplicationHelper module ApplicationHelper
include Educoder::I18n include Educoder::I18n
include GitHelper
ONE_MINUTE = 60 * 1000 ONE_MINUTE = 60 * 1000
ONE_HOUR = 60 * ONE_MINUTE ONE_HOUR = 60 * ONE_MINUTE
@ -332,6 +333,7 @@ module ApplicationHelper
raw arr.join('') raw arr.join('')
end end
end end

@ -1,5 +1,6 @@
module ExercisesHelper module ExercisesHelper
# include GitHelper
#获取每个学生对每个题的答案状态 #获取每个学生对每个题的答案状态
def get_each_student_exercise(exercise_id,exercise_questions,user_id) def get_each_student_exercise(exercise_id,exercise_questions,user_id)
@ -166,10 +167,13 @@ module ExercisesHelper
ex_score = ex&.question_score ex_score = ex&.question_score
full_scores = effictive_users.search_exercise_answer("score",ex_score).count #满分人数 full_scores = effictive_users.search_exercise_answer("score",ex_score).count #满分人数
no_full_scores = effictive_users.exercise_no_full_scores(ex_score).count #部分分数人数 no_full_scores = effictive_users.exercise_no_full_scores(ex_score).count #部分分数人数
all_zero_scores = effictive_users.search_exercise_answer("score",0.0).count #包含为0分的及未评阅的 zero_scores = effictive_users.search_exercise_answer("score",0.0).count #包含为0分的及未评阅的
review_scores = ex.exercise_answer_comments.count #主观题的评阅数量 # review_scores = ex.exercise_answer_comments.count #主观题的评阅数量
un_review_scores = effictive_users_count - review_scores #未评阅数 un_review_scores = effictive_users_count - full_scores - no_full_scores - zero_scores #未评阅数
zero_scores = all_zero_scores - un_review_scores #已评阅且答案未0分的人数 if un_review_scores < 0
un_review_scores = 0
end
# zero_scores = all_zero_scores - un_review_scores #已评阅且答案未0分的人数
main_scores_array = [full_scores,no_full_scores,zero_scores,un_review_scores] main_scores_array = [full_scores,no_full_scores,zero_scores,un_review_scores]
main_scores_array.each_with_index do |s,index| main_scores_array.each_with_index do |s,index|
if index == 0 if index == 0
@ -428,15 +432,19 @@ module ExercisesHelper
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)
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 code = nil
if exercise_cha.challenge&.path.present?
cha_path = challenge_path(exercise_cha.challenge&.path) cha_path = challenge_path(exercise_cha.challenge&.path)
game_challenge = game.game_codes.search_challenge_path(cha_path)&.first game_challenge = game.game_codes.search_challenge_path(cha_path)&.first
if game_challenge.present? if game_challenge.present?
game_code = game_challenge game_code = game_challenge
code = game_code.try(:new_code) code = game_code.try(:new_code)
else else
code = git_fle_content(exercise_cha.shixun&.repo_path,cha_path) code = git_fle_content(game.myshixun.repo_path,cha_path)
end end
end
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了涉及到code的多个版本库的修改
sx_option = { sx_option = {
:exercise_question_id => q.id, :exercise_question_id => q.id,
:exercise_shixun_challenge_id => exercise_cha.id, :exercise_shixun_challenge_id => exercise_cha.id,
@ -447,7 +455,7 @@ module ExercisesHelper
} }
ExerciseShixunAnswer.create(sx_option) ExerciseShixunAnswer.create(sx_option)
else else
ex_shixun_answer_content.first.update_column('score',exercise_cha_score) ex_shixun_answer_content.first.update_attributes(score:exercise_cha_score.round(1),answer_text:code)
end end
score5 += exercise_cha_score score5 += exercise_cha_score
else else
@ -637,7 +645,11 @@ module ExercisesHelper
end end
if student_status == 2 #当前为老师,或为学生且已提交 if student_status == 2 #当前为老师,或为学生且已提交
user_score_pre = exercise_answers.score_reviewed user_score_pre = exercise_answers.score_reviewed
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil if ques_type == 4 && user_score_pre.blank? #主观题时且没有大于0的分数时为空
user_score = nil
else
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
end
end end
if user_score.present? && (user_score > q.question_score) if user_score.present? && (user_score > q.question_score)

@ -231,9 +231,13 @@ class HomeworkCommon < ApplicationRecord
# 作业的分班设置时间 # 作业的分班设置时间
def homework_group_setting user_id def homework_group_setting user_id
if unified_setting
homework_setting = self
else
member = course.course_member(user_id) member = course.course_member(user_id)
group_setting = self.homework_group_settings.find_by_course_group_id(member.try(:course_group_id)) group_setting = self.homework_group_settings.find_by_course_group_id(member.try(:course_group_id))
homework_setting = group_setting.present? ? group_setting : self homework_setting = group_setting.present? ? group_setting : self
end
homework_setting homework_setting
end end

@ -1,6 +1,10 @@
json.question_id question.id json.question_id question.id
# json.question_number question.question_number # json.question_number question.question_number
json.q_position ques_position.present? ? ques_position : question.question_number q_positon = question.question_number
if ques_position.present?
q_positon = ques_position
end
json.q_position q_positon
json.question_title question.question_title json.question_title question.question_title
json.question_type question.question_type 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
@ -86,7 +90,7 @@ elsif question.question_type == 5
user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0
json.shixun_challenge_id s.id json.shixun_challenge_id s.id
if games_score[:games].count > 0 if games_score[:games].count > 0
json.partial! "exercises/shixun_details",games: games_score[:games], user_score: user_get_score,game_score: games_score[:game_score] json.partial! "exercises/shixun_details",games: games_score[:games], user_score: user_get_score,game_score: games_score[:game_score],shixun_challenge:s
else else
json.partial! "exercises/shixun_undo",games: [s], user_score: user_get_score ,game_score: s.question_score json.partial! "exercises/shixun_undo",games: [s], user_score: user_get_score ,game_score: s.question_score
end end

@ -26,6 +26,17 @@ json.shixun_detail do
json.position output.query_index json.position output.query_index
json.output_detail output_detail game, output json.output_detail output_detail game, output
end end
json.passed_code game.try(:lastest_code)
latest_code = nil
if shixun_challenge.challenge&.path.present?
if game.try(:lastest_code).blank?
cha_path = challenge_path(shixun_challenge.challenge&.path)
latest_code = git_fle_content(game.myshixun.repo_path,cha_path)
else
latest_code = game.try(:lastest_code)
end
end
json.passed_code latest_code
end end
end end

@ -1,3 +1,4 @@
json.content @content json.content @content
json.resubmit "#{@resubmit}" json.resubmit "#{@resubmit}"
json.sec_key "#{@sec_key}"
json.content_modified @hide_code ? false : @content_modified json.content_modified @hide_code ? false : @content_modified

@ -1,8 +1,11 @@
#json.partial! "users/users_list", users: @users #json.partial! "users/users_list", users: @users
json.user_count @users_count json.user_count @user_count
json.users do
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.lastname json.nickname user.real_name
json.school_name user.school_name json.school_name user.school_name
end end
end

Loading…
Cancel
Save