From 67c1de097c06387a19bc321fb40fee6204ddca7c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 23:00:32 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AF=84=E9=98=85=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attendances_controller.rb | 2 +- .../exercise_questions_controller.rb | 72 ++++++++++++------- ..._migrate_exercise_shixun_answer_comment.rb | 10 +++ 3 files changed, 59 insertions(+), 25 deletions(-) create mode 100644 db/migrate/20200320144644_migrate_exercise_shixun_answer_comment.rb diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb index 412b3bee6..633da5d5d 100644 --- a/app/controllers/attendances_controller.rb +++ b/app/controllers/attendances_controller.rb @@ -81,7 +81,7 @@ class AttendancesController < ApplicationController old_group_ids = @attendance.course_attendance_groups.pluck(:course_group_id) unless old_group_ids.include?(0) - all_groups_ids = old_group_ids + params[:group_ids] + all_groups_ids = old_group_ids + params[:group_ids].map(&:to_i) # 如果新增的的分班加上之前的分班是课堂的全部分班,则只需创建一条记录 if all_groups_ids.uniq.count == @course.course_groups_count @attendance.course_attendance_groups.destroy_all diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index e237f4605..18316b3ac 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -614,31 +614,21 @@ class ExerciseQuestionsController < ApplicationController @exercise_current_user.update!(ex_scores) end comments = params[:comment] - question_comment = @exercise_question.exercise_answer_comments&.first - - if question_comment.present? - comment_option = { - :comment => comments, - :score => @c_score, - :exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil, - :user_id => current_user.id - } - question_comment.update!(comment_option) - @exercise_comments = question_comment + + if @exercise_question.question_type == Exercise::PRACTICAL + shixun_answer = ExerciseShixunAnswer.find_by(exercise_question_id: @exercise_question.id, user_id: @user_id, exercise_shixun_challenge_id: @shixun_a_id) + answer_comment = shixun_answer&.exercise_answer_comments.take else - 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, - :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_answer_comment_id - } - @exercise_comments = ExerciseAnswerComment.new(comment_option) - @exercise_comments.save! + question_answer = ExerciseAnswer.find_by(exercise_question_id: @exercise_question.id, user_id: @user_id) + answer_comment = question_answer&.exercise_answer_comments.take + end - # 给被评阅人发送消息,同一个教师评阅无需重复发消息 + if answer_comment.present? + answer_comment.update!(:comment => comments, :score => @c_score) + else + ExerciseAnswerComment.create!(:comment => comments, :score => @c_score, :user_id => current_user.id, + :exercise_question_id => @exercise_question.id, :exercise_shixun_answer_id => shixun_answer&.id, + :exercise_answer_id => question_answer&.id) unless Tiding.where(user_id: @user_id, trigger_user_id: current_user.id, parent_container_id: @exercise.id, parent_container_type: "ExerciseScore").exists? Tiding.create!(user_id: @user_id, trigger_user_id: current_user.id, container_id: @exercise.id, @@ -646,8 +636,42 @@ class ExerciseQuestionsController < ApplicationController parent_container_type: "ExerciseScore", belong_container_id: @course.id, belong_container_type: 'Course', tiding_type: "Exercise") end - end + + # question_comment = @exercise_question.exercise_answer_comments&.first + # + # if question_comment.present? + # comment_option = { + # :comment => comments, + # :score => @c_score, + # :exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil, + # :user_id => current_user.id + # } + # question_comment.update!(comment_option) + # @exercise_comments = question_comment + # else + # 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, + # :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_answer_comment_id + # } + # @exercise_comments = ExerciseAnswerComment.new(comment_option) + # @exercise_comments.save! + # + # # 给被评阅人发送消息,同一个教师评阅无需重复发消息 + # + # unless Tiding.where(user_id: @user_id, trigger_user_id: current_user.id, parent_container_id: @exercise.id, parent_container_type: "ExerciseScore").exists? + # Tiding.create!(user_id: @user_id, trigger_user_id: current_user.id, container_id: @exercise.id, + # container_type: "Exercise", parent_container_id: @exercise.id, + # parent_container_type: "ExerciseScore", belong_container_id: @course.id, + # belong_container_type: 'Course', tiding_type: "Exercise") + # end + # + # end end end diff --git a/db/migrate/20200320144644_migrate_exercise_shixun_answer_comment.rb b/db/migrate/20200320144644_migrate_exercise_shixun_answer_comment.rb new file mode 100644 index 000000000..99998830c --- /dev/null +++ b/db/migrate/20200320144644_migrate_exercise_shixun_answer_comment.rb @@ -0,0 +1,10 @@ +class MigrateExerciseShixunAnswerComment < ActiveRecord::Migration[5.2] + def change + ExerciseAnswerComment.where.not(exercise_shixun_answer_id: ExerciseShixunAnswer.all).where("exercise_shixun_answer_id is not null and exercise_answer_id is not null").each do |answer| + exercise_shixun_answer = ExerciseShixunAnswer.find_by(id: answer.exercise_answer_id) + if exercise_shixun_answer.present? + answer.update_columns(exercise_shixun_answer_id: exercise_shixun_answer&.id) + end + end + end +end From 8893575db7d79c6fde0e20f3836fbc7758af62be Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 23:03:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...lections.rb => 20200320152708_uniq_index_on_collections.rb} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename db/migrate/{20200320082708_uniq_index_on_collections.rb => 20200320152708_uniq_index_on_collections.rb} (50%) diff --git a/db/migrate/20200320082708_uniq_index_on_collections.rb b/db/migrate/20200320152708_uniq_index_on_collections.rb similarity index 50% rename from db/migrate/20200320082708_uniq_index_on_collections.rb rename to db/migrate/20200320152708_uniq_index_on_collections.rb index 30b55def4..65eecb309 100644 --- a/db/migrate/20200320082708_uniq_index_on_collections.rb +++ b/db/migrate/20200320152708_uniq_index_on_collections.rb @@ -1,6 +1,7 @@ class UniqIndexOnCollections < ActiveRecord::Migration[5.2] def change remove_index :collections, [:container_type, :container_id] - add_index :collections, [:container_type, :container_id], unique: true + add_index :collections, [:container_type, :container_id] + add_index :collections, [:user_id, :container_type, :container_id], unique: true end end From 6f75f984eefda61fadee51cffb3b6e351efb00dc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 23:12:48 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E7=9A=84=E5=AE=9E=E8=AE=AD=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/users/shixun_service.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/services/users/shixun_service.rb b/app/services/users/shixun_service.rb index 6b17ea379..0efe2dd1a 100644 --- a/app/services/users/shixun_service.rb +++ b/app/services/users/shixun_service.rb @@ -34,8 +34,10 @@ class Users::ShixunService def status_filter(relations) case params[:category] - when 'study', 'collect' then + when 'study' then study_shixun_status_filter(relations) + when 'collect' then + collect_shixun_status_filter(relations) when 'manage' then manage_shixun_status_filter(relations) else @@ -66,6 +68,16 @@ class Users::ShixunService relations end + def collect_shixun_status_filter relations + passed_shixun_ids = user.myshixuns.where(shixun_id: relations, status: 1).pluck(:shixun_id) + if params[:status] == 'passed' + relations = relations.where(id: passed_shixun_ids) + elsif params[:status] == 'processing' + relations = relations.where.not(id: passed_shixun_ids) + end + relations + end + def manage_shixun_status_filter(relations) if params[:status] == "publiced" relations = relations.where(public: 2) From 51e2aac019171632261f8fa1a08162ef15e572c9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 20 Mar 2020 23:35:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=95=A2=E7=9C=8B=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/course_videos.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/course_videos.json.jbuilder b/app/views/courses/course_videos.json.jbuilder index f1f173304..3ac8e7d5e 100644 --- a/app/views/courses/course_videos.json.jbuilder +++ b/app/views/courses/course_videos.json.jbuilder @@ -12,7 +12,7 @@ json.videos @videos do |video| json.course_video_id video.id json.partial! 'users/videos/video', locals: { video: video.video } json.total_time video['total_duration'].round(0) - json.people_num video['count'] + json.people_num 960 #video['count'] end end From ec9dd4121173408414439fd83073d807dcc808d7 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, 20 Mar 2020 23:36:38 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/user/usersInfo/InfosPath.js | 2 +- public/react/src/modules/user/usersInfo/InfosShixun.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/user/usersInfo/InfosPath.js b/public/react/src/modules/user/usersInfo/InfosPath.js index c03c7541f..2829342e7 100644 --- a/public/react/src/modules/user/usersInfo/InfosPath.js +++ b/public/react/src/modules/user/usersInfo/InfosPath.js @@ -289,7 +289,7 @@ class InfosPath extends Component{ lineHeight: "41px", marginTop: "10px", }}> - 共参与{totalCount}个{category?category=="manage"?"发布":"学习":"实践课程"} + {category && category == "collect" ?"共收藏":"共参与"}{totalCount}个{category?category=="manage"?"发布":"学习":"实践课程"} - 共参与{totalCount}个{category?category=="manage"?"发布":"学习":"实训"} + {category && category == "collect"?"共收藏":"共参与"}{totalCount}个{category?category=="manage"?"发布":"学习":"实训"} Date: Fri, 20 Mar 2020 23:37:11 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=BF=98=E5=8E=9Ffix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/course_videos.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/course_videos.json.jbuilder b/app/views/courses/course_videos.json.jbuilder index 3ac8e7d5e..f1f173304 100644 --- a/app/views/courses/course_videos.json.jbuilder +++ b/app/views/courses/course_videos.json.jbuilder @@ -12,7 +12,7 @@ json.videos @videos do |video| json.course_video_id video.id json.partial! 'users/videos/video', locals: { video: video.video } json.total_time video['total_duration'].round(0) - json.people_num 960 #video['count'] + json.people_num video['count'] end end