Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_forum
杨树明 5 years ago
commit b6c616e473

@ -246,13 +246,15 @@ class HomeworkCommonsController < ApplicationController
student_works = @homework.student_works.where(user_id: user_ids)
end
myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id, user_id: user_ids).
includes(:games).where(games: {challenge_id: @homework.homework_challenge_settings.pluck(:challenge_id)})
student_works = student_works.includes(:challenge_work_scores)
challenge_settings = @homework.homework_challenge_settings
challenge_setting_ids = challenge_settings.pluck(:challenge_id)
myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id, user_id: user_ids).includes(:games)
myshixuns.find_each(batch_size: 100) do |myshixun|
work = student_works.select{|work| work.user_id == myshixun.user_id}.first
if work && myshixun
games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id))
games = myshixun.games.select{|game| challenge_setting_ids.include?(game.challenge_id)}
HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings
end
end

@ -286,7 +286,7 @@ class HomeworksService
challenge_setting = challenge_settings.select{|setting| setting.challenge_id == game.challenge_id}.first
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 => game.challenge_id).last
adjust_score = work.challenge_work_scores.select{|work_score| work_score.challenge_id == game.challenge_id}.last
final_score += if adjust_score.present?
adjust_score.score
elsif homework.homework_detail_manual.answer_open_evaluation
@ -300,6 +300,17 @@ class HomeworksService
end
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
if work.work_status == 0
is_complete = myshixun_endtime && (myshixun_endtime < setting_time.end_time)
if is_complete || (myshixun.created_at < setting_time.end_time && (!homework.allow_late || setting_time.end_time >= Time.now))
work.work_status = 1
elsif homework.allow_late && myshixun.created_at < homework.late_time
work.work_status = 2
end
end
if work.work_status != 0
if myshixun_endtime.present?
work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i
@ -314,18 +325,9 @@ class HomeworksService
end
end
if work.work_status == 0
is_complete = myshixun_endtime && (myshixun_endtime < setting_time.end_time)
if is_complete || (myshixun.created_at < setting_time.end_time && (!homework.allow_late || setting_time.end_time >= Time.now))
work.work_status = 1
elsif homework.allow_late && myshixun.created_at < homework.late_time
work.work_status = 2
end
work.late_penalty = work.work_status == 2 ? homework.late_penalty : 0
work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at
work.myshixun_id = myshixun.id
end
work.update_time = myshixun.updated_at
work.final_score = final_score
@ -336,3 +338,4 @@ class HomeworksService
work.save!
end
end
end

Binary file not shown.

@ -120,35 +120,35 @@ class ExerciseDisplay extends Component{
return <SingleDisplay {...this.props} {...item} index={index} {...commonHandler}
displayCount={exercise_questions.length} showActionButton={false}
displayCount={exercise_questions.length} showActionButton={false} key={index}
></SingleDisplay>
} else if (item.question_type == 2) {
return <JudgeDisplay
showActionButton={false}
showActionButton={false} key={index}
{...this.props} {...item} index={index} {...commonHandler} ></JudgeDisplay>
} else if (item.question_type == 3) {
return <NullDisplay
showActionButton={false}
showActionButton={false} key={index}
{...this.props} {...item} index={index} {...commonHandler} ></NullDisplay>
} else if (item.question_type == 4) {
return <MainDisplay
showActionButton={false}
showActionButton={false} key={index}
{...this.props} {...item} index={index} {...commonHandler} ></MainDisplay>
} else if (item.question_type == 5) {
return <ShixunDisplay Testpapersettinghomepage
showActionButton={false}
showActionButton={false} key={index}
{...this.props} {...item} index={index} {...commonHandler} ></ShixunDisplay>
}

@ -407,11 +407,11 @@ class ExerciceNew extends Component{
}
`}</style>
<div className="edu-class-container edu-position courseForm">
<CBreadcrumb items={[
{ current_user && <CBreadcrumb items={[
{ to: current_user.first_category_url, name: this.props.coursedata ? this.props.coursedata.name : ''},
{ to: `/courses/${courseId}/exercises/${left_banner_id}`, name: '试卷列表' },
{ name: this.isEdit ? '编辑试卷' : '新建试卷'}
]}></CBreadcrumb>
]}></CBreadcrumb> }
<p className="clearfix mt20 mb20">
<span className="fl font-24 color-grey-3">{this.isEdit ? "编辑" : "新建"}试卷</span>

Loading…
Cancel
Save