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

dev_cs
hjm 5 years ago
commit 9145b51906

@ -23,7 +23,7 @@ module GitHelper
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
# 字符编码问题GB18030编码识别率不行 # 字符编码问题GB18030编码识别率不行
decode_content = decode_content =
if cd["encoding"] == 'GB18030' && cd['confidence'] == 1.0 if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '}) content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
else else
content.force_encoding('UTF-8') content.force_encoding('UTF-8')

@ -494,6 +494,7 @@ class ExerciseQuestionsController < ApplicationController
def adjust_score def adjust_score
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
ex_all_scores = @exercise.exercise_questions.pluck(:question_score).sum
ex_obj_score = @exercise_current_user.objective_score #全部客观题得分 ex_obj_score = @exercise_current_user.objective_score #全部客观题得分
ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分 ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分
ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分 ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
@ -501,9 +502,11 @@ class ExerciseQuestionsController < ApplicationController
if ex_answers.present? #学生有回答时 取学生的答题得分否则0分 if ex_answers.present? #学生有回答时 取学生的答题得分否则0分
answer_choice_array = [] answer_choice_array = []
ex_answers.each do |a| ex_answers.each do |a|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 if a.try(:exercise_choice).try(:choice_position).present?
answer_choice_array.push(a&.exercise_choice&.choice_position) #学生答案的位置
end
end end
user_answer_content = answer_choice_array.sort user_answer_content = answer_choice_array.reject(&:blank?).sort
standard_answer = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).sort standard_answer = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).sort
if standard_answer.size == 1 # 老数据需要判断学生答题是否正确, 正确取原题得分否则是0分 if standard_answer.size == 1 # 老数据需要判断学生答题是否正确, 正确取原题得分否则是0分
standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort
@ -535,6 +538,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > ex_all_scores
total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
@ -563,6 +568,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > ex_all_scores
total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
@ -587,6 +594,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = ex_obj_score + new_sub_score total_scores = ex_obj_score + new_sub_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > ex_all_scores
total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:subjective_score => new_sub_score, :subjective_score => new_sub_score,
@ -615,6 +624,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0 if total_scores < 0.0
total_scores = 0.0 total_scores = 0.0
elsif total_scores > ex_all_scores
total_scores = ex_all_scores
end end
ex_scores = { ex_scores = {
:objective_score => new_obj_score, :objective_score => new_obj_score,
@ -623,23 +634,26 @@ class ExerciseQuestionsController < ApplicationController
@exercise_current_user.update_attributes(ex_scores) @exercise_current_user.update_attributes(ex_scores)
end end
comments = params[:comment] comments = params[:comment]
question_comment = @exercise_question.exercise_answer_comments.first question_comment = @exercise_question.exercise_answer_comments&.first
if question_comment.present? if question_comment.present?
comment_option = { comment_option = {
:comment => comments.present? ? comments : question_comment.comment, :comment => comments,
:score => @c_score, :score => @c_score,
:exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil :exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil,
:user_id => current_user.id
} }
question_comment.update_attributes(comment_option) question_comment.update_attributes(comment_option)
@exercise_comments = question_comment @exercise_comments = question_comment
else else
ex_answer_comment_id = @exercise_question.exercise_answers.find_by(user_id: @user_id).try(:id)
comment_option = { comment_option = {
:user_id => current_user.id, :user_id => current_user.id,
:comment => comments, :comment => comments,
:score => @c_score, :score => @c_score,
:exercise_question_id => @exercise_question.id, :exercise_question_id => @exercise_question.id,
:exercise_shixun_answer_id => @shixun_a_id.present? ? @shixun_a_id : nil, :exercise_shixun_answer_id => @shixun_a_id.present? ? @shixun_a_id : nil,
:exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil :exercise_answer_id => ex_answer_comment_id
} }
@exercise_comments = ExerciseAnswerComment.new(comment_option) @exercise_comments = ExerciseAnswerComment.new(comment_option)
@exercise_comments.save @exercise_comments.save

@ -3,7 +3,7 @@ class ExerciseAnswerComment < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :exercise_question belongs_to :exercise_question
belongs_to :exercise_shixun_answer, optional: true belongs_to :exercise_shixun_answer, optional: true
belongs_to :exercise_answer,optional: true belongs_to :exercise_answer, optional: true
scope :search_answer_comments, lambda {|name,ids| where("#{name}":ids)} scope :search_answer_comments, lambda {|name,ids| where("#{name}":ids)}
end end

@ -139,10 +139,11 @@ class NewShixunModel extends Component{
belongto=(value)=>{ belongto=(value)=>{
this.setState({ this.setState({
type:value, type:value,
keyword:undefined keyword:undefined,
page:1
}) })
let{page,status,keyword,order,diff,limit}=this.state; let{status,order,diff,limit}=this.state;
this.getdatalist(page,value,status,keyword,order,diff,limit) this.getdatalist(1,value,status,undefined,order,diff,limit)
} }
updatedlist=(order)=>{ updatedlist=(order)=>{

@ -199,7 +199,7 @@ class ExerciseReviewAndAnswer extends Component{
result.data && result.data.exercise_questions.length>0 && result.data.exercise_questions.map((item,key)=>{ result.data && result.data.exercise_questions.length>0 && result.data.exercise_questions.map((item,key)=>{
if( item.question_type == 4 && item.answer_status == 0 ){ if( item.question_type == 4 && item.answer_status == 0 ){
ajustSore.push({ ajustSore.push({
inputSore:undefined, inputSore:0,
desc:undefined, desc:undefined,
id:item.question_id, id:item.question_id,
position:item.q_position, position:item.q_position,
@ -268,15 +268,15 @@ class ExerciseReviewAndAnswer extends Component{
exercise_questions : update(prevState.exercise_questions, {[key]: { setScore: {$set: flag == undefined || flag==false ? true : false}}}) exercise_questions : update(prevState.exercise_questions, {[key]: { setScore: {$set: flag == undefined || flag==false ? true : false}}})
}),()=>{ }),()=>{
if (position && type && (flag == undefined || flag==false)) { if (position && type && (flag == undefined || flag==false)) {
$("#input_"+position+"_"+type).focus();
$("html").animate({ scrollTop: $("#Anchor_"+position+"_"+type).offset().top - 150 }); $("html").animate({ scrollTop: $("#Anchor_"+position+"_"+type).offset().top - 150 });
if(id){ if(id){
let { ajustSore } = this.state; let { ajustSore } = this.state;
let obj = ajustSore.filter(obj => obj.id === id).length > 0; let obj = ajustSore.filter(obj => obj.id === id).length > 0;
if(!obj){ if(!obj){
ajustSore.push({ ajustSore.push({
id, id,
inputSore:undefined, inputSore:0,
desc:undefined, desc:undefined,
position:position, position:position,
setTip:"" setTip:""
@ -382,26 +382,26 @@ class ExerciseReviewAndAnswer extends Component{
}).then((result)=>{ }).then((result)=>{
if(result.status==200){ if(result.status==200){
this.props.showNotification('调分成功'); this.props.showNotification('调分成功');
this.getInfo();
// let statusScore = score==0 ? 0 : score > 0 && score < maxScore ? 2 : 1;
let statusScore = score==0 ? 0 : score > 0 && score < maxScore ? 2 : 1; // this.setState(
// (prevState) => ({
this.setState( // exercise_questions : update(prevState.exercise_questions, {[key]: { user_score: {$set: parseFloat(score).toFixed(1)},answer_status : {$set: statusScore},question_comments:{$set:result.data.question_comments} }}),
(prevState) => ({ // })
exercise_questions : update(prevState.exercise_questions, {[key]: { user_score: {$set: parseFloat(score).toFixed(1)},answer_status : {$set: statusScore},question_comments:{$set:result.data.question_comments} }}), // )
})
)
this.setState( // this.setState(
(prevState) => ({ // (prevState) => ({
ajustSore : update(prevState.ajustSore, {[index]: { desc: {$set: undefined},inputSore:{ $set:undefined }}}) // ajustSore : update(prevState.ajustSore, {[index]: { desc: {$set: undefined},inputSore:{ $set:undefined }}})
}) // })
) // )
let {exerciseTotalScore} = this.state; // let {exerciseTotalScore} = this.state;
let newScore = parseFloat(parseFloat(exerciseTotalScore)+parseFloat(score)-parseFloat(oldScore)).toFixed(1); // let newScore = parseFloat(parseFloat(exerciseTotalScore)+parseFloat(score)-parseFloat(oldScore)).toFixed(1);
this.setState({ // this.setState({
exerciseTotalScore:newScore // exerciseTotalScore:newScore
}) // })
this.showSetScore(key,true); // this.showSetScore(key,true);
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
@ -932,6 +932,7 @@ class ExerciseReviewAndAnswer extends Component{
precision={1} precision={1}
className={ list && list.length>0 && list[0].setTip !="" ? "edu-txt-center winput-115-40 fl mt3 noticeTip inputNumber30" : "edu-txt-center winput-115-40 fl mt3 inputNumber30"} className={ list && list.length>0 && list[0].setTip !="" ? "edu-txt-center winput-115-40 fl mt3 noticeTip inputNumber30" : "edu-txt-center winput-115-40 fl mt3 inputNumber30"}
onChange={(value)=>this.inputScore(value,item.question_id)} onChange={(value)=>this.inputScore(value,item.question_id)}
id={`${"input_"+item.q_position+"_"+item.question_type}`}
></InputNumber> ></InputNumber>
<span className="ml5"></span> <span className="ml5"></span>
{ {

Loading…
Cancel
Save