From 155ac1639e3eded56230812df645d66189812932 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 13 Mar 2020 21:25:46 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_answers_controller.rb | 13 +------- app/controllers/exercises_controller.rb | 21 +++++-------- app/helpers/exercises_helper.rb | 31 +++++++++++++++++++ 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index 31df2291e..12a18d0a0 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -102,18 +102,7 @@ class ExerciseAnswersController < ApplicationController normal_status(-1,"已提交/已结束的试卷不允许修改!") else if (@exercise_user_status == Exercise::DEADLINE && @exercise_user.commit_status == 0) || (@exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + @exercise.time.to_i.minutes) < Time.now)) - objective_score = calculate_student_score(@exercise,current_user,Time.now)[:total_score] - subjective_score = @exercise_user.subjective_score < 0.0 ? 0.0 : @exercise_user.subjective_score - total_score = objective_score + subjective_score - commit_option = { - :status => 1, - :commit_status => 1, - :end_at => Time.now, - :objective_score => objective_score, - :score => total_score, - :subjective_score => subjective_score - } - @exercise_user.update!(commit_option) + commit_exercise_user @exercise, @exercise_user normal_status(-1,"试卷提交时间已截止!") end end diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 73bd07954..3717ec18e 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -982,11 +982,17 @@ class ExercisesController < ApplicationController @shixun_undo = 0 @ques_undo = 0 ex_answer_time = @exercise.time.to_i + exercise_user = @exercise.exercise_users.find_by(user_id: current_user.id) if ex_answer_time > 0 #有剩余时间的时候 user_left_time = get_exercise_left_time(@exercise, current_user) @ex_end_time = Time.now + user_left_time.to_i.seconds + + # 提交用户试卷 + commit_exercise_user @exercise, exercise_user if user_left_time.nil? else @ex_end_time = @exercise.get_exercise_end_time(current_user.id) + + commit_exercise_user @exercise, exercise_user if @ex_end_time < Time.now end # @ex_end_time = @exercise.get_exercise_end_time(current_user.id) # if ex_answer_time > 0 @@ -1033,20 +1039,7 @@ class ExercisesController < ApplicationController can_commit_exercise = true end if can_commit_exercise - objective_score = calculate_student_score(@exercise, current_user, Time.now)[:total_score] - subjective_score = @answer_committed_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = objective_score + total_score_subjective_score - commit_option = { - :status => 1, - :commit_status => 1, - :end_at => Time.now, - :objective_score => objective_score, - :score => total_score, - :subjective_score => subjective_score, - :commit_method => @answer_committed_user&.commit_method.to_i > 0 ? @answer_committed_user&.commit_method.to_i : params[:commit_method].to_i - } - @answer_committed_user.update!(commit_option) + commit_exercise_user @exercise, @answer_committed_user, Time.now CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id) normal_status(0, "试卷提交成功!") else diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 0ec1f6cb3..845aeb583 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -961,4 +961,35 @@ module ExercisesHelper def content_line(content) content.split(/\r?\n/).length + 1 end + + def commit_exercise_user exercise, exercise_user, commit_time = nil + exercise_end_time = exercise.get_exercise_end_time(exercise_user.user_id) #没有考虑分班的情况 + objective_score = calculate_student_score(exercise, exercise_user.user, exercise_end_time)[:total_score] + subjective_score = exercise_user.subjective_score < 0.0 ? 0.0 : exercise_user.subjective_score + total_score = objective_score + subjective_score + + if commit_time.nil? + if exercise.time > 0 + start_time = Time.at(exercise_user.start_at + exercise.time * 60) + commit_time = start_time > exercise_end_time ? exercise_end_time : start_time + commit_method = start_time > exercise_end_time ? 3 : 2 + else + commit_method = 3 + commit_time = exercise_end_time + end + else + commit_method = 1 + end + + commit_option = { + :status => 1, + :commit_status => 1, + :end_at => commit_time, + :objective_score => objective_score, + :score => total_score, + :subjective_score => subjective_score, + :commit_method => commit_method + } + exercise_user.update!(commit_option) + end end From 58e183f3067719756b5926796ba419491e59d892 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 13 Mar 2020 23:26:57 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E8=AF=95=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 8 ++++++++ app/helpers/exercises_helper.rb | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 3717ec18e..19b0f30fa 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1190,10 +1190,18 @@ class ExercisesController < ApplicationController @exercise_users_size = @exercise_users_list.size + if @exercise.time > 0 + start_time = Time.current - @exercise.time * 60 + if @exercise_users_list.where("start_at <= '#{Time.at(start_time)}' and commit_status = 0").count > 0 + + end + end + # 分页 @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) + else @exercise_users_list = [] @export_ex_users = @exercise_users_list diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 845aeb583..26125ae23 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -971,15 +971,16 @@ module ExercisesHelper if commit_time.nil? if exercise.time > 0 start_time = Time.at(exercise_user.start_at + exercise.time * 60) - commit_time = start_time > exercise_end_time ? exercise_end_time : start_time + end_time = start_time > exercise_end_time ? exercise_end_time : start_time commit_method = start_time > exercise_end_time ? 3 : 2 else commit_method = 3 - commit_time = exercise_end_time + end_time = exercise_end_time end else commit_method = 1 end + commit_time = commit_time.present? && end_time > commit_time ? commit_time : end_time commit_option = { :status => 1, From f232066bc4b4bd00847aefdd56e5f023be14e38e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 19 Mar 2020 22:30:39 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B0=86=E5=80=92=E8=AE=A1=E6=97=B6=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E4=B8=94=E6=9C=AA=E6=8F=90=E4=BA=A4=E7=9A=84=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E6=8F=90=E4=BA=A4=E7=AD=94=E9=A2=98=E5=B9=B6=E7=AE=97?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 7 ++++--- app/jobs/end_exercise_calculate_job.rb | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 19b0f30fa..c6e7a1eda 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -816,7 +816,7 @@ class ExercisesController < ApplicationController ex_user_ids = exercise_users.pluck(:id) - EndExerciseCalculateJob.perform_later(ex_user_ids, exercise, Time.now.to_s) + EndExerciseCalculateJob.perform_later(ex_user_ids, exercise, Time.now.to_s, true, 4) # exercise_users.each do |user| # if user.commit_status == 0 && user.start_at.present? # objective_score = calculate_student_score(exercise,user.user)[:total_score] @@ -1192,8 +1192,9 @@ class ExercisesController < ApplicationController if @exercise.time > 0 start_time = Time.current - @exercise.time * 60 - if @exercise_users_list.where("start_at <= '#{Time.at(start_time)}' and commit_status = 0").count > 0 - + ex_user_ids = @exercise_users_list.where("start_at <= '#{Time.at(start_time)}' and commit_status = 0").pluck(:user_id) + if ex_user_ids.size > 0 + EndExerciseCalculateJob.perform_later(ex_user_ids, @exercise, Time.now.to_s, false, 2) end end diff --git a/app/jobs/end_exercise_calculate_job.rb b/app/jobs/end_exercise_calculate_job.rb index 251496cb5..28f1f6901 100644 --- a/app/jobs/end_exercise_calculate_job.rb +++ b/app/jobs/end_exercise_calculate_job.rb @@ -5,10 +5,12 @@ class EndExerciseCalculateJob < ApplicationJob queue_as :default - def perform(ex_user_ids,exercise,end_time) + def perform(ex_user_ids,exercise,end_time,work_time,commit_method) exercise_users = ExerciseUser.where(id: ex_user_ids) exercise_users.each do |user| if user.commit_status == 0 && user.start_at.present? + end_at = work_time ? end_time : Time.at(user.start_at + exercise.time * 60) + objective_score = calculate_student_score(exercise,user.user,end_time.to_time)[:total_score] user_sub_score = user.subjective_score subjective_score = user_sub_score < 0.0 ? 0.0 : user_sub_score @@ -16,11 +18,11 @@ class EndExerciseCalculateJob < ApplicationJob commit_option = { :status => 1, :commit_status => 1, - :end_at => Time.now, + :end_at => end_at, :objective_score => objective_score, :score => total_score, :subjective_score => user_sub_score, - :commit_method => user&.commit_method.to_i > 0 ? user&.commit_method.to_i : 4 + :commit_method => user&.commit_method.to_i > 0 ? user&.commit_method.to_i : commit_method } user.update_attributes(commit_option) end From fa402ef3c4f4fdc6f270009b77ea8fbccf00b42f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 15:53:36 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/collection.rb | 3 +++ db/migrate/20200320074850_create_collections.rb | 13 +++++++++++++ spec/models/collection_spec.rb | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 app/models/collection.rb create mode 100644 db/migrate/20200320074850_create_collections.rb create mode 100644 spec/models/collection_spec.rb diff --git a/app/models/collection.rb b/app/models/collection.rb new file mode 100644 index 000000000..3baf96931 --- /dev/null +++ b/app/models/collection.rb @@ -0,0 +1,3 @@ +class Collection < ApplicationRecord + belongs_to :user +end diff --git a/db/migrate/20200320074850_create_collections.rb b/db/migrate/20200320074850_create_collections.rb new file mode 100644 index 000000000..7bc172c5d --- /dev/null +++ b/db/migrate/20200320074850_create_collections.rb @@ -0,0 +1,13 @@ +class CreateCollections < ActiveRecord::Migration[5.2] + def change + create_table :collections do |t| + t.references :user, index: true + t.integer :container_id + t.string :container_type + + t.timestamps + end + + add_index :collections, [:container_type, :container_id] + end +end diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb new file mode 100644 index 000000000..284719b0f --- /dev/null +++ b/spec/models/collection_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Collection, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 428f62f504426d935c73daab0d6cc3419612efcc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 16:08:59 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=A7=86=E8=A7=92?= =?UTF-8?q?=E7=9A=84=E6=AD=A3=E5=9C=A8=E7=AD=BE=E5=88=B0=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- app/helpers/weapps/attendances_helper.rb | 4 +++- app/views/attendances/index.json.jbuilder | 4 +++- .../weapps/attendances/_student_attendance.json.jbuilder | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15e795bdb..fa4648852 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 3117 end diff --git a/app/helpers/weapps/attendances_helper.rb b/app/helpers/weapps/attendances_helper.rb index e0223ad74..f2b6d55d7 100644 --- a/app/helpers/weapps/attendances_helper.rb +++ b/app/helpers/weapps/attendances_helper.rb @@ -2,7 +2,9 @@ module Weapps::AttendancesHelper def student_attendance_status attendance, user st_attendance = attendance.course_member_attendances.find_by(user_id: user.id) - st_attendance.present? ? st_attendance.attendance_status : "ABSENCE" + attendance_status = st_attendance.present? ? st_attendance.attendance_status : "ABSENCE" + attendance_mode = st_attendance.present? ? st_attendance.attendance_mode : "DEFAULT" + {attendance_status: attendance_status, attendance_mode: attendance_mode} end def group_attendance_count attendances, member_ids diff --git a/app/views/attendances/index.json.jbuilder b/app/views/attendances/index.json.jbuilder index b44f9a4fe..b42420b5b 100644 --- a/app/views/attendances/index.json.jbuilder +++ b/app/views/attendances/index.json.jbuilder @@ -11,7 +11,9 @@ json.attendances @attendances do |attendance| json.edit_auth @user_course_identity < Course::PROFESSOR || attendance.user_id == User.current.id if @user_course_identity == Course::STUDENT - json.attendance_status student_attendance_status(attendance, User.current) + student_attendance_status = student_attendance_status(attendance, User.current) + json.attendance_status student_attendance_status[:attendance_status] + json.attendance_mode student_attendance_status[:attendance_mode] end end diff --git a/app/views/weapps/attendances/_student_attendance.json.jbuilder b/app/views/weapps/attendances/_student_attendance.json.jbuilder index 6fd5e9d70..94c600831 100644 --- a/app/views/weapps/attendances/_student_attendance.json.jbuilder +++ b/app/views/weapps/attendances/_student_attendance.json.jbuilder @@ -2,4 +2,7 @@ json.(attendance, :id, :name, :mode) json.attendance_date attendance.attendance_date.strftime("%Y/%m/%d") json.start_time attendance.start_time.strftime("%H:%M") json.end_time attendance.end_time.strftime("%H:%M") -json.attendance_status student_attendance_status(attendance, User.current) \ No newline at end of file + +student_attendance_status = student_attendance_status(attendance, User.current) +json.attendance_status student_attendance_status[:attendance_status] +json.attendance_mode student_attendance_status[:attendance_mode] \ No newline at end of file From b8c6913f5d497feafe5782f199684c077075933f 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 16:26:42 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/signin/component/Teacherentry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/signin/component/Teacherentry.js b/public/react/src/modules/courses/signin/component/Teacherentry.js index b8f2cf526..228e25334 100644 --- a/public/react/src/modules/courses/signin/component/Teacherentry.js +++ b/public/react/src/modules/courses/signin/component/Teacherentry.js @@ -163,7 +163,7 @@ class Teacherentry extends Component { { item.attendance_status? ( - item.attendance_status==="ABSENCE"? + item.attendance_status==="ABSENCE"&&item.attendance_mode!="TEACHER"?
{e.stopPropagation();this.props.Signin(item.mode,item.id,item.attendance_code)}}> 签到
From 1adeea7f8890c14f2dbda9fe6c0cad56318dd56f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 16:35:49 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=92=8C=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/collections_controller.rb | 21 +++++++++++++++++++ app/models/collection.rb | 1 + app/models/shixun.rb | 3 +++ app/models/subject.rb | 3 +++ app/models/user.rb | 2 ++ config/routes.rb | 4 ++++ ...0200320082708_uniq_index_on_collections.rb | 6 ++++++ 7 files changed, 40 insertions(+) create mode 100644 app/controllers/collections_controller.rb create mode 100644 db/migrate/20200320082708_uniq_index_on_collections.rb diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb new file mode 100644 index 000000000..1d1c03742 --- /dev/null +++ b/app/controllers/collections_controller.rb @@ -0,0 +1,21 @@ +class CollectionsController < ApplicationController + + before_action :require_login + + def create + tip_exception("勿重复收藏") if current_user.collections.find_by(create_params).present? + current_user.collections.create!(create_params) + normal_status("收藏成功,您可以在个人主页对应的栏目中查看") + end + + def cancel + collection = current_user.collections.find_by!(create_params) + collection.destroy! + normal_status("操作成功") + end + + private + def create_params + params.permit(:container_id, :container_type) + end +end \ No newline at end of file diff --git a/app/models/collection.rb b/app/models/collection.rb index 3baf96931..53d2b0f8b 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,3 +1,4 @@ class Collection < ApplicationRecord belongs_to :user + belongs_to :container, polymorphic: true, optional: true end diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 5caacebce..f9adf237c 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -53,6 +53,9 @@ class Shixun < ApplicationRecord has_many :shixun_service_configs, :dependent => :destroy has_many :tidings, as: :container, dependent: :destroy + # 收藏 + has_many :collections, as: :container, dependent: :destroy + # 实训审核记录 has_many :shixun_reviews, -> {order("shixun_reviews.created_at desc")}, :dependent => :destroy diff --git a/app/models/subject.rb b/app/models/subject.rb index 387e5adb1..a7ad74d61 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -16,6 +16,9 @@ class Subject < ApplicationRecord has_many :subject_appointments, dependent: :destroy + # 收藏 + has_many :collections, as: :container, dependent: :destroy + has_many :subject_members, ->{ order("subject_members.position asc")}, dependent: :destroy has_many :users, through: :subject_members has_many :tidings, as: :container, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index fb4cc50da..b909d6dd6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -48,6 +48,8 @@ class User < ApplicationRecord has_many :course_messages has_many :courses, foreign_key: 'tea_id', dependent: :destroy + has_many :collections, dependent: :destroy + #试卷 has_many :exercise_banks, :dependent => :destroy has_many :exercise_users, :dependent => :destroy diff --git a/config/routes.rb b/config/routes.rb index da07c8d89..f858056a7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -306,6 +306,10 @@ Rails.application.routes.draw do resources :subject_lists resources :shixun_lists + resources :collections do + delete :cancel, on: :collection + end + resources :shixuns, param: :identifier do collection do diff --git a/db/migrate/20200320082708_uniq_index_on_collections.rb b/db/migrate/20200320082708_uniq_index_on_collections.rb new file mode 100644 index 000000000..30b55def4 --- /dev/null +++ b/db/migrate/20200320082708_uniq_index_on_collections.rb @@ -0,0 +1,6 @@ +class UniqIndexOnCollections < ActiveRecord::Migration[5.2] + def change + remove_index :collections, [:container_type, :container_id] + add_index :collections, [:container_type, :container_id], unique: true + end +end From 2fcbd4c3512cd0a4c4ac22c025834f7a71842cc8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 17:31:21 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/collection.rb | 3 +++ app/models/user.rb | 7 +++++-- app/services/users/shixun_service.rb | 8 +++++--- app/services/users/subject_service.rb | 7 +++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/models/collection.rb b/app/models/collection.rb index 53d2b0f8b..4ed77db60 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,4 +1,7 @@ class Collection < ApplicationRecord belongs_to :user belongs_to :container, polymorphic: true, optional: true + + scope :shixuns, -> {where(container_type: 'Shixun')} + scope :subjects, -> {where(container_type: 'Subject')} end diff --git a/app/models/user.rb b/app/models/user.rb index b909d6dd6..02a4eba85 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -48,8 +48,6 @@ class User < ApplicationRecord has_many :course_messages has_many :courses, foreign_key: 'tea_id', dependent: :destroy - has_many :collections, dependent: :destroy - #试卷 has_many :exercise_banks, :dependent => :destroy has_many :exercise_users, :dependent => :destroy @@ -119,6 +117,11 @@ class User < ApplicationRecord has_many :manage_course_members, -> { teachers_and_admin }, class_name: 'CourseMember' has_many :manage_courses, through: :manage_course_members, source: :course + has_many :collections, dependent: :destroy + has_many :shixun_collections, -> { shixuns }, class_name: 'Collection' + has_many :subject_collections, -> { subjects }, class_name: 'Collection' + + # 关注 # has_many :be_watchers, foreign_key: :user_id, dependent: :destroy # 我的关注 # has_many :be_watcher_users, through: :be_watchers, dependent: :destroy # 我关注的用户 diff --git a/app/services/users/shixun_service.rb b/app/services/users/shixun_service.rb index b13b0ab1f..7e95cda84 100644 --- a/app/services/users/shixun_service.rb +++ b/app/services/users/shixun_service.rb @@ -24,15 +24,17 @@ class Users::ShixunService user.study_shixuns.where(shixuns: {id: laboratory.shixuns}) when 'manage' then laboratory.shixuns.where(id: user.shixuns) + when 'collect' then + laboratory.shixuns.where(id: user.shixun_collections.pluck(:container_id)) else - ids = user.study_shixuns.pluck(:id) + user.shixuns.pluck(:id) + ids = user.study_shixuns.pluck(:id) + user.shixuns.pluck(:id) + user.shixun_collections.pluck(:container_id) laboratory.shixuns.where(id: ids) end end def status_filter(relations) case params[:category] - when 'study' then + when 'study', 'collect' then study_shixun_status_filter(relations) when 'manage' then manage_shixun_status_filter(relations) @@ -97,7 +99,7 @@ class Users::ShixunService end case params[:category] - when 'study' then + when 'study', 'collect' then relations.order("myshixuns.#{sort_by} #{sort_direction}") when 'manage' then relations.order("shixuns.#{sort_by} #{sort_direction}") diff --git a/app/services/users/subject_service.rb b/app/services/users/subject_service.rb index d0b995c8e..a8b9b32fb 100644 --- a/app/services/users/subject_service.rb +++ b/app/services/users/subject_service.rb @@ -25,10 +25,13 @@ class Users::SubjectService Subject.joins(stage_shixuns: { shixun: :myshixuns }).where(myshixuns: { user_id: user.id }) when 'manage' then Subject.joins(:subject_members).where(subject_members: { user_id: user.id }) + when 'collect' then + Subject.where(id: user.subject_collections.pluck(:container_id)) else study_subject_ids = StageShixun.where(shixun_id: user.myshixuns.pluck(:shixun_id)).pluck(:subject_id) manage_subject_ids = user.subject_members.pluck(:subject_id) - Subject.where(id: study_subject_ids + manage_subject_ids) + collect_subject_ids = user.subject_collections.pluck(:container_id) + Subject.where(id: study_subject_ids + manage_subject_ids + collect_subject_ids) end end @@ -45,7 +48,7 @@ class Users::SubjectService return relations unless self_or_admin? case params[:category] - when 'study' then + when 'study', 'collect' then study_subject_status_filter(relations) when 'manage' then manage_subject_status_filter(relations) From 7eb1f03034a6bb8c7412e2478da2d1b3dc2c687c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 20 Mar 2020 17:57:42 +0800 Subject: [PATCH 09/23] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- app/controllers/weapps/subjects_controller.rb | 2 +- app/queries/weapps/subject_query.rb | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index c5cae99c4..b6fdf8ea9 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -17,7 +17,7 @@ class SubjectsController < ApplicationController include CustomSortable def index - subjects = Weapps::SubjectQuery.call(current_laboratory, params) + subjects = Weapps::SubjectQuery.call(current_laboratory, params, "web") @subject_count = subjects.map(&:id).size @subjects = paginate subjects.includes(:shixuns, :repertoire) end diff --git a/app/controllers/weapps/subjects_controller.rb b/app/controllers/weapps/subjects_controller.rb index e5c3eb316..e1e50cc40 100644 --- a/app/controllers/weapps/subjects_controller.rb +++ b/app/controllers/weapps/subjects_controller.rb @@ -4,7 +4,7 @@ class Weapps::SubjectsController < Weapps::BaseController # 首页 def index - subjects = Weapps::SubjectQuery.call(current_laboratory, params) + subjects = Weapps::SubjectQuery.call(current_laboratory, params, "wechat") @subject_count = subjects.map(&:id).size @subjects = paginate subjects end diff --git a/app/queries/weapps/subject_query.rb b/app/queries/weapps/subject_query.rb index 180176ce2..c0fbbf653 100644 --- a/app/queries/weapps/subject_query.rb +++ b/app/queries/weapps/subject_query.rb @@ -2,13 +2,20 @@ class Weapps::SubjectQuery < ApplicationQuery include CustomSortable attr_reader :params - def initialize(current_laboratory, params) + def initialize(current_laboratory, params, device) @current_laboratory = current_laboratory @params = params + @device = device end def call - subjects = @current_laboratory.subjects.unhidden.publiced.show_moblied + Rails.logger.info("##### @device: #{@device}") + subjects = + if @device == "wechat" + @current_laboratory.subjects.unhidden.publiced + else + @current_laboratory.subjects.unhidden.publiced.show_moblied + end # 课程体系的过滤 if params[:sub_discipline_id].present? From 3abae101417db1f75a0efeea4db273ac72c92379 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 17:57:48 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=92=8C=E5=AE=9E?= =?UTF-8?q?=E8=B7=B5=E8=AF=BE=E7=A8=8B=E7=9A=84=E6=94=B6=E8=97=8F=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 4 ++++ app/views/shixuns/show.json.jbuilder | 2 ++ app/views/subjects/show.json.jbuilder | 2 ++ 3 files changed, 8 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 02a4eba85..2a1eb7195 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -649,6 +649,10 @@ class User < ApplicationRecord Educoder::Utils.random_hex(16) end + def is_collect? container + collections.where(container: container).exists? + end + # 全部已认证 def all_certified? authentication? && professional_certification? diff --git a/app/views/shixuns/show.json.jbuilder b/app/views/shixuns/show.json.jbuilder index 4a0c3ebd6..eeddd9149 100644 --- a/app/views/shixuns/show.json.jbuilder +++ b/app/views/shixuns/show.json.jbuilder @@ -1,5 +1,7 @@ json.fork_from @fork_from json.identity User.current.shixun_identity(@shixun) +json.is_collect @user.is_collect?(@shixun) + json.power @power json.partial! 'shixuns/top', locals: { shixun: @shixun, current_myshixun: @current_myshixun } json.secret_repository @shixun.shixun_secret_repository.present? diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index d25437f0a..6a7954d0b 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -5,6 +5,8 @@ json.challenges_count @subject.subject_challenge_count json.subject_score @subject.all_score json.member_count @subject.member_count +json.is_collect @user.is_collect?(@subject) + json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin? json.publish_status publish_status(@subject, @is_manager) json.public_status public_status(@subject, @is_manager, @user) From 6936f05778f712eef6674f64008f3b07682e304f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 20 Mar 2020 18:00:56 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=92=8Cweb=E7=AB=AF?= =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B=E9=A6=96=E9=A1=B5=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=86=85=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/weapps/subject_query.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/queries/weapps/subject_query.rb b/app/queries/weapps/subject_query.rb index c0fbbf653..ca0c437a9 100644 --- a/app/queries/weapps/subject_query.rb +++ b/app/queries/weapps/subject_query.rb @@ -12,9 +12,9 @@ class Weapps::SubjectQuery < ApplicationQuery Rails.logger.info("##### @device: #{@device}") subjects = if @device == "wechat" - @current_laboratory.subjects.unhidden.publiced - else @current_laboratory.subjects.unhidden.publiced.show_moblied + else + @current_laboratory.subjects.unhidden.publiced end # 课程体系的过滤 From 1be131321c8183f519b3a86dc6b2921b99f10f25 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 18:09:21 +0800 Subject: [PATCH 12/23] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 8 ++++---- app/views/shixuns/show.json.jbuilder | 2 +- app/views/subjects/show.json.jbuilder | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2a1eb7195..531782ac0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -424,6 +424,10 @@ class User < ApplicationRecord end end + def is_collect? container + collections.where(container: container).exists? + end + # 实训用户身份 def shixun_identity(shixun) @identity = @@ -649,10 +653,6 @@ class User < ApplicationRecord Educoder::Utils.random_hex(16) end - def is_collect? container - collections.where(container: container).exists? - end - # 全部已认证 def all_certified? authentication? && professional_certification? diff --git a/app/views/shixuns/show.json.jbuilder b/app/views/shixuns/show.json.jbuilder index eeddd9149..7f8a1db50 100644 --- a/app/views/shixuns/show.json.jbuilder +++ b/app/views/shixuns/show.json.jbuilder @@ -1,6 +1,6 @@ json.fork_from @fork_from json.identity User.current.shixun_identity(@shixun) -json.is_collect @user.is_collect?(@shixun) +json.is_collect @user&.is_collect?(@shixun) json.power @power json.partial! 'shixuns/top', locals: { shixun: @shixun, current_myshixun: @current_myshixun } diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 6a7954d0b..577424fb4 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -5,7 +5,7 @@ json.challenges_count @subject.subject_challenge_count json.subject_score @subject.all_score json.member_count @subject.member_count -json.is_collect @user.is_collect?(@subject) +json.is_collect @user&.is_collect?(@subject) json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin? json.publish_status publish_status(@subject, @is_manager) From c4774a75aa4bc8faaf822572e7a9d0cd8bfe6ea9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 18:12:33 +0800 Subject: [PATCH 13/23] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/show.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/show.json.jbuilder b/app/views/shixuns/show.json.jbuilder index 7f8a1db50..404acb4fa 100644 --- a/app/views/shixuns/show.json.jbuilder +++ b/app/views/shixuns/show.json.jbuilder @@ -1,6 +1,6 @@ json.fork_from @fork_from json.identity User.current.shixun_identity(@shixun) -json.is_collect @user&.is_collect?(@shixun) +json.is_collect User.current&.is_collect?(@shixun) json.power @power json.partial! 'shixuns/top', locals: { shixun: @shixun, current_myshixun: @current_myshixun } From 763791f93694ae7fae03a8169189c071a66c91fa Mon Sep 17 00:00:00 2001 From: anke1460 Date: Fri, 20 Mar 2020 18:20:15 +0800 Subject: [PATCH 14/23] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=90=8E=E7=BB=99=E5=AD=A6=E7=94=9F=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tidings_controller.rb | 4 ++- app/decorators/tiding_decorator.rb | 3 +++ app/jobs/course_video_uploaded_job.rb | 25 +++++++++++++++++++ app/services/videos/batch_publish_service.rb | 1 + .../videos/dispatch_callback_service.rb | 1 + config/locales/tidings/zh-CN.yml | 1 + 6 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/jobs/course_video_uploaded_job.rb diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb index 91d6c095d..91836a12a 100644 --- a/app/controllers/tidings_controller.rb +++ b/app/controllers/tidings_controller.rb @@ -12,7 +12,7 @@ class TidingsController < ApplicationController case params[:type] when 'notice' then 'System' when 'apply' then 'Apply' - when 'course' then %w(HomeworkCommon Exercise Poll GraduationTask GraduationTopic) + when 'course' then %w(HomeworkCommon Exercise Poll GraduationTask GraduationTopic PublishCourseVideo) when 'project' then 'Project' when 'interaction' then %w(Comment Mentioned Praise Fan) when 'project_package' then %w(Created Destroyed Bidding BiddingEnd BiddingWon BiddingLost) @@ -25,6 +25,8 @@ class TidingsController < ApplicationController tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package' + + @count = tidings.count @tidings = paginate(tidings.order(created_at: :desc), per_page: 10) end diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index 8d266b7df..4e640a28b 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -403,6 +403,8 @@ module TidingDecorator def video_content if tiding_type == 'System' I18n.t(locale_format(tiding_type, status), reason: extra) % container.try(:title) + elsif tiding_type == 'PublishCourseVideo' + I18n.t(locale_format(tiding_type)) % [belong_container&.name] else I18n.t(locale_format(tiding_type)) % [container.try(:title) || extra] end @@ -419,4 +421,5 @@ module TidingDecorator def hack_content I18n.t(locale_format(parent_container_type)) % (container&.name || extra) end + end diff --git a/app/jobs/course_video_uploaded_job.rb b/app/jobs/course_video_uploaded_job.rb new file mode 100644 index 000000000..71dfaa600 --- /dev/null +++ b/app/jobs/course_video_uploaded_job.rb @@ -0,0 +1,25 @@ +class CourseVideoUploadedJob < ApplicationJob + queue_as :notify + + def perform(video_id) + video = Video.select("id, user_id").find_by(id: video_id) + course_ids = video&.course_videos&.pluck(:course_id) + + return unless course_ids.present? + + course_members = CourseMember.where(course_id: course_ids, role: 'STUDENT').select("user_id, course_id") + Tiding.bulk_insert do |worker| + course_members.find_each do |m| + worker.add( + user_id: m.user_id, + tiding_type: 'PublishCourseVideo', + trigger_user_id: video.user_id, + container_id: video.id, + container_type: 'Video', + belong_container_type: 'Course', + belong_container_id: m.course_id) + end + end + end + +end diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 3ddc54967..543497e9e 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -52,6 +52,7 @@ class Videos::BatchPublishService < ApplicationService if param[:course_id].present? video.video_applies.create!(status: "agreed") + CourseVideoUploadedJob.perform_later(video.id) if video.transcoded else video.video_applies.create! end diff --git a/app/services/videos/dispatch_callback_service.rb b/app/services/videos/dispatch_callback_service.rb index 4ff94a1c4..49b1d5935 100644 --- a/app/services/videos/dispatch_callback_service.rb +++ b/app/services/videos/dispatch_callback_service.rb @@ -22,6 +22,7 @@ class Videos::DispatchCallbackService < ApplicationService when 'StreamTranscodeComplete' then # 转码完成 #return if video.play_url.present? video.update!(play_url: params['FileUrl'], transcoded: true) + CourseVideoUploadedJob.perform_later(video.id) if video.video_applies.exists?(status: 'agreed') #通过的情况基本上是课堂视频 when 'DeleteMediaComplete' #完成云端视频删除 video.update_column(:delete_state, Video::FINISH_DELETE) end diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index cda146780..5eb6ee759 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -236,6 +236,7 @@ System: 1_end: "你提交的发布视频申请:%s,审核已通过" 2_end: "你提交的发布视频申请:%s,审核未通过
原因:%{reason}" + PublishCourseVideo_end: "在课堂 %s 发布了视频,观看视频可以增加平时分哦~" PublicCourseStart_end: "你报名参与的开放课程:%s,将于%s正式开课" SubjectStartCourse_end: "您创建的开放课程:%s 已达到开课人数要求。您可以在24小时内自主开设新一期课程。如果超过24小时未开课,平台将自动开课并复制您上一期的课程内容。" LiveLink_end: "%s 直播将于30分钟后开始" From dae962c6de92ca1f3fc5e485038809da018b1656 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 19:04:43 +0800 Subject: [PATCH 15/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=AF=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/shixuns/create_shixun_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/shixuns/create_shixun_service.rb b/app/services/shixuns/create_shixun_service.rb index 2a66cf2fb..c3a46285e 100644 --- a/app/services/shixuns/create_shixun_service.rb +++ b/app/services/shixuns/create_shixun_service.rb @@ -12,6 +12,7 @@ class CreateShixunService < ApplicationService identifier = Util::UUID.generate_identifier(Shixun, 8) shixun.identifier= identifier shixun.user_id = user.id + shixun.can_copy = 1 main_mirror = MirrorRepository.find params[:main_type] sub_mirrors = MirrorRepository.where(id: params[:sub_type]) begin From 7dba79a61813ebeafa40d5fc987c85babd7dd735 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 19:21:56 +0800 Subject: [PATCH 16/23] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attendances_controller.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb index 256e651e8..412b3bee6 100644 --- a/app/controllers/attendances_controller.rb +++ b/app/controllers/attendances_controller.rb @@ -79,8 +79,26 @@ class AttendancesController < ApplicationController new_end_time = "#{params[:attendance_date]} #{params[:end_time]}".to_time @attendance.update!(update_params) - # 如果历史签到变为了正在签到,将未创建的学生签到数据补上 - if a_end_time < Time.current && new_end_time > Time.current + 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] + # 如果新增的的分班加上之前的分班是课堂的全部分班,则只需创建一条记录 + if all_groups_ids.uniq.count == @course.course_groups_count + @attendance.course_attendance_groups.destroy_all + @attendance.course_attendance_groups.create!(course_group_id: 0, course_id: @attendance.course_id) + new_group = true + else + new_group_ids = params[:group_ids] - old_group_ids + new_group_ids.each do |group_id| + @attendance.course_attendance_groups.create!(course_group_id: group_id, course_id: @attendance.course_id) + new_group = true + end + end + + end + + # 如果新增了分班或者历史签到变为了正在签到,将未创建的学生签到数据补上 + if new_group || (a_end_time < Time.current && new_end_time > Time.current) create_absence_student_data end render_ok From 4aa70fc370d8a26370a1861668e7c38de4a4fe56 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 19:24:08 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E3=80=81=E8=AF=BE?= =?UTF-8?q?=E5=A0=82=E6=94=B6=E8=97=8F=E5=8A=9F=E8=83=BD=E3=80=81=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E5=A4=8D=E5=88=B6=E5=8F=AF=E9=80=89=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/signin/model/Createsignmodel.js | 30 +++++++--- .../src/modules/paths/PathDetail/DetailTop.js | 50 ++++++++++++++++ .../paths/PathDetail/PathDetailIndex.js | 6 +- public/react/src/modules/tpm/TPMBanner.js | 60 ++++++++++++++++++- public/react/src/modules/tpm/TPMIndex.js | 1 + 5 files changed, 132 insertions(+), 15 deletions(-) diff --git a/public/react/src/modules/courses/signin/model/Createsignmodel.js b/public/react/src/modules/courses/signin/model/Createsignmodel.js index 99f616204..6b504e4b7 100644 --- a/public/react/src/modules/courses/signin/model/Createsignmodel.js +++ b/public/react/src/modules/courses/signin/model/Createsignmodel.js @@ -54,7 +54,8 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })( end_time: date }); } - componentDidMount() { + getgroup_idss=(course_groups)=>{ + let newcourse_groups=course_groups; if(this.props.type==="edit"){ let newlist=[] if(this.props.attendancesdata.groups.length>0){ @@ -63,15 +64,25 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })( }) } - console.log(this.props.attendancesdata.start_time) - // console.log() + newlist.map((item,key)=>{ + newcourse_groups.map((i,k)=>{ + if(i.id===item){ + i.disabled=true + } + }) + }) + console.log(newlist) + // this.setState({ + // + // }) this.setState({ attendance_date: this.props.attendancesdata.attendance_date, start_time:new Date(this.props.attendancesdata.start_time), end_time:new Date(this.props.attendancesdata.end_time), newmode:this.props.attendancesdata.mode, + course_groups:newcourse_groups }) @@ -85,6 +96,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })( }else{ this.setState({ start_time: new Date("2000-01-01T09:00:00.000+08:00"), + course_groups:newcourse_groups }) this.props.form.setFieldsValue({ @@ -92,15 +104,15 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })( }); } + } + componentDidMount() { const coursesId=this.props.match.params.coursesId; let newurl=`/courses/${coursesId}/all_course_groups.json`; axios.get(newurl).then((response) => { + this.getgroup_idss(response.data.course_groups) + }) - this.setState({ - course_groups:response.data.course_groups - }) - }) } @@ -269,12 +281,12 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })( {getFieldDecorator('group_ids')( 0?"不选择分班时默认选择全部学生":'暂无分班,将默认选择课堂全部学生'} getPopupContainer={trigger => trigger.parentNode} - // disabled={this.props&&this.props.type==="edit"?true:false} +