From 562959b1a102cd14cc8bec3770e03090280c3dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Tue, 27 Aug 2019 11:17:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/gradinforms/Bullsubdirectory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js b/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js index 45da1773b..b9ec4b75c 100644 --- a/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js +++ b/public/react/src/modules/courses/gradinforms/Bullsubdirectory.js @@ -167,7 +167,7 @@ class Bullsubdirectory extends Component{
-
+
{myname}
From e0c1f30a06a3225fd0f0a6858d33a628d14a79b0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 27 Aug 2019 11:18:16 +0800 Subject: [PATCH 2/4] change judge show --- .../_exercise_questions.json.jbuilder | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 940022a9f..ca8ea7e6b 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -20,10 +20,20 @@ if question.question_type <= 2 #当为选择题或判断题时,只显示选 #TODO: 旧版本来一个题只有一个标准答案的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) standard_answer_b = standard_answers_array.join("").include?(a.choice_position.to_s) user_answer_b = user_answer.include?(a.id) + choice_text = a.choice_text + if question.question_type == 2 + if choice_text == "对" + choice_text = "正确" + end + if choice_text == "错" + choice_text = "错误" + end + end json.c_position (index+1) if ex_choice_random_boolean #当选项随机时,选项位置以此为准,否则不出现 json.choice_id a.id # json.choice_text (edit_type.present? || question.question_type == 2) ? a.choice_text : "#{(index+65).chr}.#{a.choice_text}" - json.choice_text a.choice_text + + json.choice_text choice_text json.choice_position a.choice_position if exercise_type == 1 || exercise_type == 4 #1为教师编辑/预览 试卷或问题,2为空白试卷,即标准答案和用户答案都不显示,3为用户开始答题的显示,4为老师评阅试卷或学生在截止后查看试卷 json.standard_boolean standard_answer_b From 48d1e13e9d84943886dce827bfaf1e5fd54995fd Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 27 Aug 2019 11:21:04 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 ++ app/controllers/subjects_controller.rb | 34 +++++++++++++++++-- app/views/subjects/right_banner.json.jbuilder | 8 ++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 9e87d3799..dc47b6562 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -74,6 +74,7 @@ class ChallengesController < ApplicationController ChallengeTag.create(:name => tag, :challenge_choose_id => @challenge_choose.id, :challenge_id => @challenge.id) end end + @challenge.update_column(:score, @challenge.challenge_chooses.sum(:score)) end rescue Exception => e raise ActiveRecord::Rollback @@ -95,6 +96,7 @@ class ChallengesController < ApplicationController @challenge.update_column(:modify_time, Time.now) end @challenge_choose.update_attributes(chooce_params) + @challenge.update_column(:score, @challenge.challenge_chooses.sum(:score)) # 单选多选题的更新 category = @challenge_choose.standard_answer.length > 1 ? 2 : 1 @challenge_choose.update_column(:category, category) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index a62707536..f7dd520f6 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -101,8 +101,9 @@ class SubjectsController < ApplicationController @tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq # 用户获取的实训标签 # @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq - @user_tags = user_shixun_tags challenge_ids, @user.id - @my_subject_progress = @subject.my_subject_progress + + # 用户进展 + user_subject_progress(challenge_ids) end def new @@ -436,4 +437,33 @@ class SubjectsController < ApplicationController tip_exception("403", "") end end + + # 用户进展和获取的标签 + def user_subject_progress challenge_ids + pass_games = Game.select(:id, :cost_time, :challenge_id).where(status: 2, user_id: current_user.id, challenge_id: challenge_ids) + @all_score = Challenge.where(id: challenge_ids).sum(:score) + + # 如果没有通关的,没必要再继续统计了 + if pass_games.blank? + @my_score = 0 + @learned = 0 + @time = 0 + @user_tags = [] + else + pass_challenge_ids = pass_games.map(&:challenge_id) + subject_challenge_count = @subject.shixuns.sum(:challenges_count) + # 用户通关获得的标签 + @user_tags = ChallengeTag.where(challenge_id: pass_challenge_ids).pluck(:name) + # 用户学习进度 + @learned = + subject_challenge_count == 0 ? 0 : + ((pass_challenge_ids.size.to_f / subject_challenge_count).round(2) * 100).to_i + # 用户通关分数 + @my_score = Challenge.where(id: pass_challenge_ids).pluck(:score).sum + @time = pass_games.map(&:cost_time).sum + end + + + end + end diff --git a/app/views/subjects/right_banner.json.jbuilder b/app/views/subjects/right_banner.json.jbuilder index 9ca42c5bc..a289ad0a9 100644 --- a/app/views/subjects/right_banner.json.jbuilder +++ b/app/views/subjects/right_banner.json.jbuilder @@ -14,8 +14,8 @@ end # 我的进展 json.progress do - json.my_score @subject.my_subject_score - json.all_score @subject.all_score - json.learned @subject.my_subject_progress - json.time @subject.my_consume_time + json.my_score @my_score + json.all_score @all_score + json.learned @learned + json.time @time end \ No newline at end of file From 2b6ee76c0f5e14b7eccfd44df10c962eb69502fb Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Tue, 27 Aug 2019 11:22:51 +0800 Subject: [PATCH 4/4] cdn ali-cdn.educoder.net --- public/react/scripts/build.js | 2 +- public/react/src/public-path.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index d600d6068..19f5d03dc 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -207,7 +207,7 @@ function generateNewIndexJsp() { if (window.location.host == 'pre-newweb.educoder.net') { _host = 'https://testali-cdn.educoder.net/react/build/' } else if (window.location.host == 'www.educoder.net') { - _host = 'https://ali-newweb.educoder.net/react/build/' + _host = 'https://ali-cdn.educoder.net/react/build/' } document.write('