From 1c535ff934a24c20ab52e4cb743ba42cbc78c6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 27 Sep 2019 10:28:35 +0800 Subject: [PATCH 1/2] =?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/tpm/shixunchild/Repository/Repository.js | 2 +- .../modules/tpm/shixunchild/Repository/RepositoryAddFile.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js index 58379b1e8..85659a3a6 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js @@ -151,7 +151,7 @@ class Repository extends Component {
+ onClick={() => { $('#repository_url_tip').css('display') === 'none'}}>知道了 diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js index 7fe6e2bcd..9ca535bb4 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryAddFile.js @@ -92,7 +92,7 @@ class RepositoryAddFile extends Component { if(!value){ callback('文件名不能为空'); }else if (value == "/" || value.indexOf('.') == -1 ) { - callback('请输入正确的文件路径,如:src/HelloWord.java'); + callback('请输入正确的文件路径,如:src/HelloWorld.java'); }else{ callback(); } @@ -162,7 +162,7 @@ class RepositoryAddFile extends Component { validator:this.checkPath }] })( - + )} From e683b25ead9f89b44ae402ed03972dccffa39a80 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 27 Sep 2019 10:31:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/helpers/courses_helper.rb | 4 ++-- app/models/course.rb | 5 ++--- app/views/courses/online_learning.json.jbuilder | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0e093460f..4bfc236a1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -272,7 +272,7 @@ class CoursesController < ApplicationController @stages = @course.course_stages.includes(:shixuns) @user = current_user @myshixuns = @user.myshixuns.where(shixun_id: @course.course_stage_shixuns.pluck(:shixun_id)) - @start_learning = @user_course_identity == Course::STUDENT && @course.learning?(current_user.id) + @start_learning = @user_course_identity == Course::STUDENT && @myshixuns.present? end def search_course_list diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 5ca4eb773..d670614d5 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -269,8 +269,8 @@ module CoursesHelper group_info end - def last_subject_shixun user_id, course - myshixun = Myshixun.where(user_id: user_id, shixun_id: course.shixuns).order("updated_at desc").first + def last_subject_shixun course, myshixuns + myshixun = myshixuns.sort{|x,y| y[:updated_at] <=> x[:updated_at] }.first return "" unless myshixun stage_shixun = course.course_stage_shixuns.where(shixun_id: myshixun.shixun_id).take progress = stage_shixun&.course_stage&.position.to_s + "-" + stage_shixun&.position.to_s + " " + myshixun.shixun&.name diff --git a/app/models/course.rb b/app/models/course.rb index ba818449e..6dd361733 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -354,9 +354,8 @@ class Course < ApplicationRecord Myshixun.where(user_id: user_id, shixun_id: shixuns).exists? end - def my_subject_progress - my_challenge_count = Game.joins(:challenge).where(user_id: User.current.id, status: 2, challenges: {shixun_id: shixuns.published_closed}). - pluck(:challenge_id).uniq.size + def my_subject_progress myshixuns + my_challenge_count = Game.where(myshixun_id: myshixuns.pluck(:id), status: 2).pluck(:challenge_id).uniq.size course_challeng_count = shixuns.pluck(:challenges_count).sum count = course_challeng_count == 0 ? 0 : ((my_challenge_count.to_f / course_challeng_count).round(2) * 100).to_i end diff --git a/app/views/courses/online_learning.json.jbuilder b/app/views/courses/online_learning.json.jbuilder index 95b44238c..d6b3db136 100644 --- a/app/views/courses/online_learning.json.jbuilder +++ b/app/views/courses/online_learning.json.jbuilder @@ -7,6 +7,6 @@ end json.start_learning @start_learning json.subject_id @subject.id -json.learned @start_learning ? @course.my_subject_progress : 0 +json.learned @start_learning ? @course.my_subject_progress(@myshixuns) : 0 -json.last_shixun @start_learning ? last_subject_shixun(@user.id, @course) : "" \ No newline at end of file +json.last_shixun @start_learning ? last_subject_shixun(@course, @myshixuns) : "" \ No newline at end of file