From e45e15a45105f2871eedc089485d1546bcbc108e Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Thu, 12 Sep 2019 15:54:58 +0800
Subject: [PATCH 01/13] =?UTF-8?q?=E8=B0=83=E5=88=86=E6=88=90=E5=8A=9F-?=
=?UTF-8?q?=E9=87=8D=E6=96=B0=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../exercise/ExerciseReviewAndAnswer.js | 39 ++++++++++---------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js
index 97b6a5174..780b87688 100644
--- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js
+++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js
@@ -268,8 +268,8 @@ class ExerciseReviewAndAnswer extends Component{
exercise_questions : update(prevState.exercise_questions, {[key]: { setScore: {$set: flag == undefined || flag==false ? true : false}}})
}),()=>{
if (position && type && (flag == undefined || flag==false)) {
+ $("#input_"+position+"_"+type).focus();
$("html").animate({ scrollTop: $("#Anchor_"+position+"_"+type).offset().top - 150 });
-
if(id){
let { ajustSore } = this.state;
let obj = ajustSore.filter(obj => obj.id === id).length > 0;
@@ -382,26 +382,26 @@ class ExerciseReviewAndAnswer extends Component{
}).then((result)=>{
if(result.status==200){
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) => ({
- 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(
+ // (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(
- (prevState) => ({
- ajustSore : update(prevState.ajustSore, {[index]: { desc: {$set: undefined},inputSore:{ $set:undefined }}})
- })
- )
- let {exerciseTotalScore} = this.state;
- let newScore = parseFloat(parseFloat(exerciseTotalScore)+parseFloat(score)-parseFloat(oldScore)).toFixed(1);
- this.setState({
- exerciseTotalScore:newScore
- })
- this.showSetScore(key,true);
+ // this.setState(
+ // (prevState) => ({
+ // ajustSore : update(prevState.ajustSore, {[index]: { desc: {$set: undefined},inputSore:{ $set:undefined }}})
+ // })
+ // )
+ // let {exerciseTotalScore} = this.state;
+ // let newScore = parseFloat(parseFloat(exerciseTotalScore)+parseFloat(score)-parseFloat(oldScore)).toFixed(1);
+ // this.setState({
+ // exerciseTotalScore:newScore
+ // })
+ // this.showSetScore(key,true);
}
}).catch((error)=>{
console.log(error);
@@ -932,6 +932,7 @@ class ExerciseReviewAndAnswer extends Component{
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"}
onChange={(value)=>this.inputScore(value,item.question_id)}
+ id={`${"input_"+item.q_position+"_"+item.question_type}`}
>
分
{
From 28c2dab8bf3a1da906a160bb8d917e72a3a6316f Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Thu, 12 Sep 2019 15:58:00 +0800
Subject: [PATCH 02/13] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=B0=83=E5=88=86?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_questions_controller.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index 8cefa5071..5032cb469 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -501,9 +501,11 @@ class ExerciseQuestionsController < ApplicationController
if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分
answer_choice_array = []
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
- 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
if standard_answer.size == 1 # 老数据需要判断学生答题是否正确, 正确取原题得分,否则是0分
standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort
From 44cf413c595864ffdb525beb57d68b0cf4d0ffd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 12 Sep 2019 15:59:18 +0800
Subject: [PATCH 03/13] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/coursesPublic/NewShixunModel.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
index a8dad2eb4..b5cd13791 100644
--- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
+++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
@@ -180,7 +180,7 @@ class NewShixunModel extends Component{
diff:0,
limit:15,
})
- this.getdatalist(1,undefined,'all',value,'desc',0,15)
+ this.getdatalist(1,undefined,'all',undefined,'desc',0,15)
}
showNotification = (description, message = "提示", icon) => {
From f3f29b7a9c5ce46cee519a683917d6079929c819 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 12 Sep 2019 16:06:13 +0800
Subject: [PATCH 04/13] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/coursesPublic/NewShixunModel.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
index b5cd13791..b71d2c53f 100644
--- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
+++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
@@ -142,7 +142,7 @@ class NewShixunModel extends Component{
keyword:undefined
})
let{page,status,keyword,order,diff,limit}=this.state;
- this.getdatalist(page,value,status,keyword,order,diff,limit)
+ this.getdatalist(page,value,status,undefined,order,diff,limit)
}
updatedlist=(order)=>{
@@ -180,7 +180,7 @@ class NewShixunModel extends Component{
diff:0,
limit:15,
})
- this.getdatalist(1,undefined,'all',undefined,'desc',0,15)
+ this.getdatalist(1,undefined,'all',value,'desc',0,15)
}
showNotification = (description, message = "提示", icon) => {
From cbf0d74eea4d319311c3728c00e4f09ab8066d7e Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Thu, 12 Sep 2019 16:13:27 +0800
Subject: [PATCH 05/13] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=AC=AC=E4=B8=80?=
=?UTF-8?q?=E6=AC=A1=E8=B0=83=E5=88=86=E8=AF=84=E8=AF=AD=E6=B2=A1=E6=9C=89?=
=?UTF-8?q?=E5=87=BA=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_questions_controller.rb | 5 +++--
app/models/exercise_answer_comment.rb | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index 5032cb469..affbdcd56 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -525,7 +525,8 @@ class ExerciseQuestionsController < ApplicationController
:score => @c_score,
:answer_text => ""
}
- ExerciseAnswer.create(answer_option)
+ ex_answers = ExerciseAnswer.new(answer_option)
+ ex_answers.save
ex_answer_old = 0
end
if ex_obj_score <= 0.0
@@ -625,7 +626,7 @@ class ExerciseQuestionsController < ApplicationController
@exercise_current_user.update_attributes(ex_scores)
end
comments = params[:comment]
- question_comment = @exercise_question.exercise_answer_comments.first
+ question_comment = @exercise_question.exercise_answer_comments&.first
if question_comment.present?
comment_option = {
:comment => comments.present? ? comments : question_comment.comment,
diff --git a/app/models/exercise_answer_comment.rb b/app/models/exercise_answer_comment.rb
index 7da0ec4c7..4279ba445 100644
--- a/app/models/exercise_answer_comment.rb
+++ b/app/models/exercise_answer_comment.rb
@@ -3,7 +3,7 @@ class ExerciseAnswerComment < ApplicationRecord
belongs_to :user
belongs_to :exercise_question
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)}
end
From a9c6367ac9edf5169bdb64f82616aa08e7802a27 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Thu, 12 Sep 2019 16:18:07 +0800
Subject: [PATCH 06/13] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=B0=83=E5=88=86?=
=?UTF-8?q?=E7=9A=84=E8=AF=84=E8=AF=AD=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_questions_controller.rb | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index affbdcd56..20feaecfe 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -497,6 +497,7 @@ class ExerciseQuestionsController < ApplicationController
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_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
+ ex_answer_create = nil
if @exercise_question.question_type == Exercise::MULTIPLE
if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分
answer_choice_array = []
@@ -525,8 +526,8 @@ class ExerciseQuestionsController < ApplicationController
:score => @c_score,
:answer_text => ""
}
- ex_answers = ExerciseAnswer.new(answer_option)
- ex_answers.save
+ ex_answer_create = ExerciseAnswer.new(answer_option)
+ ex_answer_create.save
ex_answer_old = 0
end
if ex_obj_score <= 0.0
@@ -636,13 +637,21 @@ class ExerciseQuestionsController < ApplicationController
question_comment.update_attributes(comment_option)
@exercise_comments = question_comment
else
+ if ex_answers.present?
+ ex_answer_comment_id = ex_answers.first.id
+ elsif ex_answer_create.present?
+ ex_answer_comment_id = ex_answer_create.id
+ else
+ ex_answer_comment_id = nil
+ end
+
comment_option = {
:user_id => current_user.id,
:comment => comments,
:score => @c_score,
:exercise_question_id => @exercise_question.id,
: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.save
From 024a72e8ff89a9e9700e9613e430ae6f5a6099f0 Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Thu, 12 Sep 2019 16:24:47 +0800
Subject: [PATCH 07/13] =?UTF-8?q?=E8=B0=83=E5=88=86=E9=BB=98=E8=AE=A4?=
=?UTF-8?q?=E4=B8=BA0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/exercise/ExerciseReviewAndAnswer.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js
index 780b87688..f45de9b64 100644
--- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js
+++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js
@@ -199,7 +199,7 @@ class ExerciseReviewAndAnswer extends Component{
result.data && result.data.exercise_questions.length>0 && result.data.exercise_questions.map((item,key)=>{
if( item.question_type == 4 && item.answer_status == 0 ){
ajustSore.push({
- inputSore:undefined,
+ inputSore:0,
desc:undefined,
id:item.question_id,
position:item.q_position,
@@ -276,7 +276,7 @@ class ExerciseReviewAndAnswer extends Component{
if(!obj){
ajustSore.push({
id,
- inputSore:undefined,
+ inputSore:0,
desc:undefined,
position:position,
setTip:""
From 1aafcd25b5c31d64af088be4ea2c39a53ee9c2d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 12 Sep 2019 16:27:40 +0800
Subject: [PATCH 08/13] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/coursesPublic/NewShixunModel.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
index b71d2c53f..b713000cf 100644
--- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
+++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
@@ -142,7 +142,7 @@ class NewShixunModel extends Component{
keyword:undefined
})
let{page,status,keyword,order,diff,limit}=this.state;
- this.getdatalist(page,value,status,undefined,order,diff,limit)
+ this.getdatalist(1,value,status,undefined,order,diff,limit)
}
updatedlist=(order)=>{
From 9384f76b4521403e46fa948d9fe29cd092f5e342 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Thu, 12 Sep 2019 16:29:13 +0800
Subject: [PATCH 09/13] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=AF=84=E8=AF=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_questions_controller.rb | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index 20feaecfe..7e0b612ff 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -526,8 +526,7 @@ class ExerciseQuestionsController < ApplicationController
:score => @c_score,
:answer_text => ""
}
- ex_answer_create = ExerciseAnswer.new(answer_option)
- ex_answer_create.save
+ ExerciseAnswer.new(answer_option)
ex_answer_old = 0
end
if ex_obj_score <= 0.0
@@ -628,23 +627,18 @@ class ExerciseQuestionsController < ApplicationController
end
comments = params[:comment]
question_comment = @exercise_question.exercise_answer_comments&.first
+
if question_comment.present?
comment_option = {
:comment => comments.present? ? comments : question_comment.comment,
: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)
@exercise_comments = question_comment
else
- if ex_answers.present?
- ex_answer_comment_id = ex_answers.first.id
- elsif ex_answer_create.present?
- ex_answer_comment_id = ex_answer_create.id
- else
- ex_answer_comment_id = nil
- end
-
+ ex_answer_comment_id = @exercise_question.exercise_answers.find_by(user_id: @user_id).try(:id)
comment_option = {
:user_id => current_user.id,
:comment => comments,
From 7945996fe81e75b1f65f75a91445da0ad33e0204 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 12 Sep 2019 16:33:28 +0800
Subject: [PATCH 10/13] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/coursesPublic/NewShixunModel.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
index b713000cf..fbb97cbb5 100644
--- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
+++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
@@ -139,9 +139,10 @@ class NewShixunModel extends Component{
belongto=(value)=>{
this.setState({
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(1,value,status,undefined,order,diff,limit)
}
From e87a4d14c691bec5e978b06c00fc3c0315e7758c Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Thu, 12 Sep 2019 16:43:55 +0800
Subject: [PATCH 11/13] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E8=AF=84?=
=?UTF-8?q?=E9=98=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_questions_controller.rb | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index 7e0b612ff..14d2bdbd0 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -497,7 +497,6 @@ class ExerciseQuestionsController < ApplicationController
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_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
- ex_answer_create = nil
if @exercise_question.question_type == Exercise::MULTIPLE
if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分
answer_choice_array = []
@@ -526,7 +525,7 @@ class ExerciseQuestionsController < ApplicationController
:score => @c_score,
:answer_text => ""
}
- ExerciseAnswer.new(answer_option)
+ ExerciseAnswer.create(answer_option)
ex_answer_old = 0
end
if ex_obj_score <= 0.0
@@ -538,6 +537,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
+ elsif total_scores > @exercise.score
+ total_scores = @exercise.score
end
ex_scores = {
:objective_score => new_obj_score,
@@ -566,6 +567,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
+ elsif total_scores > @exercise.score
+ total_scores = @exercise.score
end
ex_scores = {
:objective_score => new_obj_score,
@@ -590,6 +593,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = ex_obj_score + new_sub_score
if total_scores < 0.0
total_scores = 0.0
+ elsif total_scores > @exercise.score
+ total_scores = @exercise.score
end
ex_scores = {
:subjective_score => new_sub_score,
@@ -618,6 +623,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
+ elsif total_scores > @exercise.score
+ total_scores = @exercise.score
end
ex_scores = {
:objective_score => new_obj_score,
@@ -630,7 +637,7 @@ class ExerciseQuestionsController < ApplicationController
if question_comment.present?
comment_option = {
- :comment => comments.present? ? comments : question_comment.comment,
+ :comment => comments,
:score => @c_score,
:exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil,
:user_id => current_user.id
From d2e449782132a8aab5fb4551741a67771c8e4949 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Thu, 12 Sep 2019 16:47:24 +0800
Subject: [PATCH 12/13] =?UTF-8?q?=E8=AF=84=E8=AF=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../exercise_questions_controller.rb | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb
index 14d2bdbd0..bb28fff54 100644
--- a/app/controllers/exercise_questions_controller.rb
+++ b/app/controllers/exercise_questions_controller.rb
@@ -494,6 +494,7 @@ class ExerciseQuestionsController < ApplicationController
def adjust_score
ActiveRecord::Base.transaction do
begin
+ ex_all_scores = @exercise.exercise_questions.pluck(:question_score).sum
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_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
@@ -537,8 +538,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
- elsif total_scores > @exercise.score
- total_scores = @exercise.score
+ elsif total_scores > ex_all_scores
+ total_scores = ex_all_scores
end
ex_scores = {
:objective_score => new_obj_score,
@@ -567,8 +568,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
- elsif total_scores > @exercise.score
- total_scores = @exercise.score
+ elsif total_scores > ex_all_scores
+ total_scores = ex_all_scores
end
ex_scores = {
:objective_score => new_obj_score,
@@ -593,8 +594,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = ex_obj_score + new_sub_score
if total_scores < 0.0
total_scores = 0.0
- elsif total_scores > @exercise.score
- total_scores = @exercise.score
+ elsif total_scores > ex_all_scores
+ total_scores = ex_all_scores
end
ex_scores = {
:subjective_score => new_sub_score,
@@ -623,8 +624,8 @@ class ExerciseQuestionsController < ApplicationController
total_scores = new_obj_score + ex_subj_score
if total_scores < 0.0
total_scores = 0.0
- elsif total_scores > @exercise.score
- total_scores = @exercise.score
+ elsif total_scores > ex_all_scores
+ total_scores = ex_all_scores
end
ex_scores = {
:objective_score => new_obj_score,
From 264f711046726dcc869af53ac483b8d491dee3c8 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 12 Sep 2019 22:33:37 +0800
Subject: [PATCH 13/13] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=86=E5=88=AB?=
=?UTF-8?q?=E7=BC=96=E7=A0=81=E4=B8=8D=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/concerns/git_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb
index c19c6fdd6..9242b87ac 100644
--- a/app/controllers/concerns/git_helper.rb
+++ b/app/controllers/concerns/git_helper.rb
@@ -23,7 +23,7 @@ module GitHelper
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
# 字符编码问题,GB18030编码识别率不行
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 => ' '})
else
content.force_encoding('UTF-8')