diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb index 03d51e1b4..dde6c4a8d 100644 --- a/app/controllers/concerns/controller_rescue_handler.rb +++ b/app/controllers/concerns/controller_rescue_handler.rb @@ -6,12 +6,17 @@ module ControllerRescueHandler Util.logger_error e render json: {status: -1, message: "接口异常"} end + rescue_from Mysql2::Error do |e| + Util.logger_error e + render json: {status: -1, message: "接口数据异常"} + end # rescue_from ActionView::MissingTemplate, with: :object_not_found # rescue_from ActiveRecord::RecordNotFound, with: :object_not_found rescue_from Educoder::TipException, with: :tip_show rescue_from ::ActionView::MissingTemplate, with: :missing_template rescue_from ActiveRecord::RecordNotFound, with: :object_not_found rescue_from ActionController::ParameterMissing, with: :render_parameter_missing + # form validation error rescue_from ActiveModel::ValidationError do |ex| render_error(ex.model.errors.full_messages.join(',')) diff --git a/app/controllers/live_links_controller.rb b/app/controllers/live_links_controller.rb index ea7155948..f4b49d4aa 100644 --- a/app/controllers/live_links_controller.rb +++ b/app/controllers/live_links_controller.rb @@ -2,14 +2,14 @@ class LiveLinksController < ApplicationController before_action :require_login before_action :find_course, only: [:index, :create] before_action :user_course_identity, :teacher_allowed, only: [:create] - before_action :edit_auth, only: [:edit, :update] + before_action :edit_auth, only: [:edit, :update, :destroy] def index lives = @course.live_links order_str = "on_status desc,id desc" @total_count = lives.size @my_live_id = @course.live_links.find_by(user_id: current_user.id)&.id - order_str = "#{@my_live_id} desc, #{order_str}" if @my_live_id.present? + order_str = "live_links.id = #{@my_live_id} desc, #{order_str}" if @my_live_id.present? lives = lives.order("#{order_str}") @lives = paginate lives.includes(user: :user_extension) end @@ -34,8 +34,6 @@ class LiveLinksController < ApplicationController # 开启时发送消息,关闭直播时删除对应的消息 if params[:on_status].to_i == 1 LivePublishJob.perform_later(current_live.id) - else - current_live.tidings.destroy_all end end else @@ -44,6 +42,11 @@ class LiveLinksController < ApplicationController render_ok end + def destroy + current_live.destroy! + render_ok + end + private def create_params diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb index 5acffcb16..9305046b0 100644 --- a/app/controllers/tidings_controller.rb +++ b/app/controllers/tidings_controller.rb @@ -19,8 +19,9 @@ class TidingsController < ApplicationController end tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present? - tidings = tidings.where(container_type: 'JoinCourse') if params[:type] == 'course_apply' - @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse').count + tidings = tidings.where(container_type: 'JoinCourse', status: 0) if params[:type] == 'course_apply' + # @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse', status: 0).count + @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse', status: 0).count tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package' diff --git a/app/models/student_work.rb b/app/models/student_work.rb index f8f3bee99..a4ae63f04 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -111,6 +111,7 @@ class StudentWork < ApplicationRecord # 作品总体评价 def overall_appraisal + return "--" if work_status == 0 case (self.work_score.to_f / homework_common.total_score).round(2) when (0.90..1.00) '优秀' diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index 068151856..bd618c2d4 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -4,6 +4,7 @@ json.course_name @course.name json.work_id @work.id json.work_efficiency @homework.work_efficiency json.has_commit @work.myshixun.present? +json.work_status @work.work_status if @shixun json.shixun_name @shixun.name # 总体评价 diff --git a/config/routes.rb b/config/routes.rb index f0c91e8f9..63a6e4494 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -550,7 +550,7 @@ Rails.application.routes.draw do end end - resources :live_links, only: [:index, :update, :create, :edit], shallow: true + resources :live_links, only: [:index, :update, :create, :edit, :destroy], shallow: true resources :homework_commons, shallow: true do diff --git a/db/migrate/20200210071320_migrate_defalut_to_tiding.rb b/db/migrate/20200210071320_migrate_defalut_to_tiding.rb new file mode 100644 index 000000000..1c0cfc8e9 --- /dev/null +++ b/db/migrate/20200210071320_migrate_defalut_to_tiding.rb @@ -0,0 +1,7 @@ +class MigrateDefalutToTiding < ActiveRecord::Migration[5.2] + def change + change_column_default :tidings, :status, from: nil, to: 0 + + Tiding.where(status: nil).update_all(status: 0) + end +end diff --git a/db/migrate/20200210074241_migrate_tiding_status.rb b/db/migrate/20200210074241_migrate_tiding_status.rb new file mode 100644 index 000000000..57e5f994d --- /dev/null +++ b/db/migrate/20200210074241_migrate_tiding_status.rb @@ -0,0 +1,9 @@ +class MigrateTidingStatus < ActiveRecord::Migration[5.2] + def change + Tiding.where(container_type: "JoinCourse", status: 0).each do |tiding| + unless CourseMessage.where(course_message_id: tiding.trigger_user_id, course_id: tiding.container_id, course_message_type: "JoinCourseRequest", status: 0).exists? + tiding.update!(status: 1) + end + end + end +end diff --git a/public/react/src/modules/courses/Video/Live.js b/public/react/src/modules/courses/Video/Live.js index 71dced679..741339723 100644 --- a/public/react/src/modules/courses/Video/Live.js +++ b/public/react/src/modules/courses/Video/Live.js @@ -7,10 +7,10 @@ import './video.css'; class Live extends Component{ render(){ - const { liveData , lives , successFunc , pageSize , changePage } = this.props; + const { liveData , lives , successFunc , pageSize , changePage , page } = this.props; return( -
+ 创建时间:{item.created_at}
+ {
+ item.op_auth ?
+
+
- EduCoder推荐您使用腾讯课堂进行直播 - 操作指引 -
- - + ) } diff --git a/public/react/src/modules/courses/Video/Video.js b/public/react/src/modules/courses/Video/Video.js index 189503be9..a9492a252 100644 --- a/public/react/src/modules/courses/Video/Video.js +++ b/public/react/src/modules/courses/Video/Video.js @@ -133,14 +133,14 @@ class Video extends Component{ } render(){ - const { count , visible , videoVisible , videoId } = this.state; + const { visible , videoVisible , videoId } = this.state; const CourseId=this.props.match.params.coursesId; const login=this.props.user&&this.props.user.login; const _inputValue = videoId && this.getCopyText(videoId.file_url, videoId.cover_url); const { admin , is_teacher ,business} = this.props.user; - const { videos , upload , uploadVideo , videoData , changePage ,pageSize } = this.props; + const { videos , upload , uploadVideo , videoData , changePage ,pageSize ,page } = this.props; const operation = admin || business || (is_teacher && this.props.checkIfProfessionalCertification()) return( @@ -209,7 +209,7 @@ class Video extends Component{ { videoData && videoData.count > pageSize &&