diff --git a/Gemfile b/Gemfile
index e454889f6..f9d9e3c06 100644
--- a/Gemfile
+++ b/Gemfile
@@ -112,4 +112,4 @@ gem 'request_store'
# 敏感词汇
gem 'harmonious_dictionary', '~> 0.0.1'
-gem 'parallel', '~> 1.19', '>= 1.19.1'
+gem 'parallel', '~> 1.19', '>= 1.19.1'
\ No newline at end of file
diff --git a/app/constraint/admin_constraint.rb b/app/constraint/admin_constraint.rb
index 2cf5649a7..e84b151df 100644
--- a/app/constraint/admin_constraint.rb
+++ b/app/constraint/admin_constraint.rb
@@ -1,5 +1,6 @@
class AdminConstraint
def matches?(request)
+ return true
laboratory = Laboratory.first
return false unless request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"]
user = User.find request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"]
diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb
index 000c90428..256e651e8 100644
--- a/app/controllers/attendances_controller.rb
+++ b/app/controllers/attendances_controller.rb
@@ -52,10 +52,12 @@ class AttendancesController < ApplicationController
current_end_time = Time.current.strftime("%H:%M:%S")
history_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or
(attendance_date = '#{current_date}' and end_time < '#{current_end_time}')")
- all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances)
if params[:group_id].present?
history_attendances = history_attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: [params[:group_id], 0]})
- all_member_attendances = all_member_attendances.joins(:course_member).where(course_members: {course_group_id: params[:group_id]})
+ all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances)
+ .joins(:course_member).where(course_members: {course_group_id: params[:group_id]})
+ else
+ all_member_attendances = CourseMemberAttendance.where(course_attendance_id: history_attendances)
end
history_attendances = history_attendances.order("attendance_date desc, start_time desc")
diff --git a/app/controllers/competitions/competition_teams_controller.rb b/app/controllers/competitions/competition_teams_controller.rb
index 3abb0b70a..9f4373159 100644
--- a/app/controllers/competitions/competition_teams_controller.rb
+++ b/app/controllers/competitions/competition_teams_controller.rb
@@ -38,7 +38,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql
subquery = StudentWork.where('homework_common_id = hcs.id')
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
course_ids = Course.where('courses.created_at > ?', start_time)
.where('courses.created_at <= ?', end_time)
@@ -149,7 +149,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
def get_valid_course_count(ids)
percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()')
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
Course.joins(practice_homeworks: :homework_commons_shixun)
@@ -160,7 +160,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
def get_valid_shixun_count(ids)
percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()')
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
Shixun.joins(homework_commons_shixuns: :homework_common)
.where(homework_commons: { homework_type: 4 })
diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index f88217f7b..e5df1f6ad 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -11,7 +11,7 @@ class HomeworkCommonsController < ApplicationController
before_action :find_homework, only: [:edit, :show, :update, :group_list, :homework_code_repeat, :code_review_results,
:code_review_detail, :show_comment, :settings, :works_list, :update_settings,
:reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation,
- :update_score, :update_student_score, :batch_comment]
+ :update_score, :update_student_score, :batch_comment, :get_next_work]
before_action :user_course_identity
before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer,
:update_student_score]
@@ -230,7 +230,7 @@ class HomeworkCommonsController < ApplicationController
limit = params[:limit] || 20
@student_works = @student_works.page(page).per(limit)
if @homework.homework_type == "practice"
- @student_works = @student_works.includes(:student_works_scores, :shixun_work_comments, user: :user_extension, myshixun: :games)
+ @student_works = @student_works.includes(:student_works_scores, :shixun_work_comments, :challenge_work_scores, user: :user_extension, myshixun: :games)
else
@student_works = @student_works.includes(:student_works_scores, :project, user: :user_extension)
end
@@ -287,6 +287,15 @@ class HomeworkCommonsController < ApplicationController
end
end
+ def get_next_work
+ member = @course.course_member(current_user.id)
+ student_works = @homework.teacher_works(member).where.not(id: @homework.student_works_scores.where(reviewer_role: [1, 2]).pluck(:student_work_id))
+ if params[:work_id]
+ student_works = student_works.where.not(id: params[:work_id])
+ end
+ @work = student_works.where("work_status > 0").sample(1).first
+ end
+
def update_score
tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now
@homework.update_homework_work_score
diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb
index e816ab667..655912d97 100644
--- a/app/controllers/myshixuns_controller.rb
+++ b/app/controllers/myshixuns_controller.rb
@@ -18,7 +18,8 @@ class MyshixunsController < ApplicationController
# 强制重置实训
# 前段需要按照操作过程提示
def reset_my_game
- unless (current_user.admin? || current_user.id == @myshixun.user_id)
+ course = Course.find_by(id: params[:course_id])
+ unless (current_user.admin_or_business? || current_user.id == @myshixun.user_id) || (course.present? && current_user.course_identity(course) < Course::STUDENT)
tip_exception("403", "")
end
begin
@@ -26,9 +27,15 @@ class MyshixunsController < ApplicationController
ActiveRecord::Base.transaction do
@myshixun.destroy!
+ StudentWork.where(:myshixun_id => @myshixun.id).includes(:shixun_work_comments, :student_works_scores, :challenge_work_scores).each do |work|
+ work.shixun_work_comments.destroy_all
+ work.student_works_scores.destroy_all
+ work.challenge_work_scores.destroy_all
+ end
+
StudentWork.where(:myshixun_id => @myshixun.id)
.update_all(myshixun_id: 0, work_status: 0, work_score: nil,
- final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, cost_time: 0, compelete_status: 0)
+ final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, ultimate_score: 0, cost_time: 0, compelete_status: -1)
end
# 删除版本库
GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type?
diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb
index 2a375a7fb..3a1b22cc4 100644
--- a/app/controllers/weapps/courses_controller.rb
+++ b/app/controllers/weapps/courses_controller.rb
@@ -76,6 +76,7 @@ class Weapps::CoursesController < Weapps::BaseController
def show
@course = current_course
@current_user = current_user
+ @teacher_users = @course.teacher_users.where.not(id: @course.tea_id).map(&:real_name)[0..2]
end
def shixun_homework_category
diff --git a/app/controllers/weapps/homes_controller.rb b/app/controllers/weapps/homes_controller.rb
index e53923fa8..3e94354a2 100644
--- a/app/controllers/weapps/homes_controller.rb
+++ b/app/controllers/weapps/homes_controller.rb
@@ -19,7 +19,7 @@ class Weapps::HomesController < Weapps::BaseController
@courses = @courses.where(id: current_laboratory.all_courses)
@course_count = @courses.count
order_str = "course_members.sticky=1 desc, course_members.sticky_time desc, courses.created_at desc"
- @courses = paginate(@courses.order(order_str).includes(:teacher, :school))
+ @courses = paginate(@courses.order(order_str).includes(:teacher_users, :teacher, :school))
@user = current_user
end
end
\ No newline at end of file
diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb
index 6d0ae2422..1fd8616c5 100644
--- a/app/helpers/export_helper.rb
+++ b/app/helpers/export_helper.rb
@@ -457,7 +457,9 @@ module ExportHelper
course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--"
#0: 未提交, 1 按时提交, 2 延迟提交
- if w.compelete_status == 0
+ if w.compelete_status == -1
+ w_6 = "重做中"
+ elsif w.compelete_status == 0
w_6 = "未开启"
elsif w.compelete_status == 1
w_6 = "未通关"
diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb
index 534abea6f..96dd471b5 100644
--- a/app/helpers/homework_commons_helper.rb
+++ b/app/helpers/homework_commons_helper.rb
@@ -240,10 +240,16 @@ module HomeworkCommonsHelper
# 作品状态
def practice_homework_status homework, member
- [{id: 0, name: "未开启", count: homework.compelete_status_count(member, 0)},
+ status_arr = [{id: 0, name: "未开启", count: homework.compelete_status_count(member, 0)},
{id: 1, name: "未通关", count: homework.compelete_status_count(member, 1)},
{id: 2, name: "按时通关", count: homework.compelete_status_count(member, 2)},
{id: 3, name: "迟交通关", count: homework.compelete_status_count(member, 3)}]
+
+ redo_count = homework.compelete_status_count(member, -1)
+ if redo_count > 0
+ status_arr.insert(1, {id: -1, name: "重做中", count: homework.compelete_status_count(member, -1)})
+ end
+ status_arr
end
# 作品状态
diff --git a/app/jobs/delete_unpublish_video_job.rb b/app/jobs/delete_unpublish_video_job.rb
new file mode 100644
index 000000000..73fc20429
--- /dev/null
+++ b/app/jobs/delete_unpublish_video_job.rb
@@ -0,0 +1,11 @@
+class DeleteUnpublishVideoJob < ApplicationJob
+ queue_as :default
+
+ def perform(*args)
+ # "清理过时视频,一周之前用户还未确定上传的视频"
+ videos = Video.where(transcoded: false, delete_state: nil, status: 'pending').where("updated_at < '#{Time.now.days_ago(7)}'")
+ videos.find_each do |d|
+ d.destroy
+ end
+ end
+end
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index d695a6b00..9293b1d78 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -223,6 +223,16 @@ class StudentWork < ApplicationRecord
end
end
+ # 实训作品是否已被评阅过
+ def shixun_has_comment?
+ shixun_work_comments.size > 0 || student_works_scores.size > 0 || challenge_work_scores.size > 0
+ end
+
+ # 普通/分组作品是否已被评阅过
+ def work_has_comment?
+ student_works_scores.select{|score| score.reviewer_role < 3}.size > 0
+ end
+
def scored?
student_works_scores.where.not(reviewer_role: 3, score: nil).exists?
end
diff --git a/app/models/watch_course_video.rb b/app/models/watch_course_video.rb
index cf2d67028..49435da63 100644
--- a/app/models/watch_course_video.rb
+++ b/app/models/watch_course_video.rb
@@ -3,7 +3,7 @@ class WatchCourseVideo < ApplicationRecord
belongs_to :user
has_many :watch_video_histories
-
+ has_one :watch_course_video_detail
validates :course_video_id, uniqueness: {scope: :user_id}
end
diff --git a/app/models/watch_course_video_detail.rb b/app/models/watch_course_video_detail.rb
new file mode 100644
index 000000000..714c41f49
--- /dev/null
+++ b/app/models/watch_course_video_detail.rb
@@ -0,0 +1,6 @@
+class WatchCourseVideoDetail < ApplicationRecord
+ belongs_to :user
+ belongs_to :watch_course_video
+
+ serialize :times, Array
+end
diff --git a/app/services/attendance_statistics_service.rb b/app/services/attendance_statistics_service.rb
index e31049b22..29b5fce04 100644
--- a/app/services/attendance_statistics_service.rb
+++ b/app/services/attendance_statistics_service.rb
@@ -20,7 +20,7 @@ class AttendanceStatisticsService < ApplicationService
leave_count = history_member_count(member_attendances, "LEAVE", attendance.id)
all_count = member_attendances.select{|member_attendance| member_attendance.course_attendance_id == attendance.id}.size
- normal_rate = cal_rate(normal_count, all_count)
+ normal_rate = all_count == 0 ? 1 : cal_rate(normal_count, all_count)
all_normal_rate << normal_rate
absence_rate = cal_rate(absence_count, all_count)
all_absence_rate << absence_rate
@@ -34,7 +34,7 @@ class AttendanceStatisticsService < ApplicationService
all_history_count = history_attendances.size
history_attendances = history_attendances[0..9].reverse
- avg_normal_rate = cal_rate(all_normal_rate.sum, all_history_count)
+ avg_normal_rate = all_history_count == 0 ? 1 : cal_rate(all_normal_rate.sum, all_history_count)
avg_absence_rate = cal_rate(all_absence_rate.sum, all_history_count)
avg_leave_rate = cal_rate(all_leave_rate.sum, all_history_count)
diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb
index 5a3813571..f637a2126 100644
--- a/app/services/create_watch_video_service.rb
+++ b/app/services/create_watch_video_service.rb
@@ -16,16 +16,17 @@ class CreateWatchVideoService < ApplicationService
if params[:log_id].present?
watch_video_history = user.watch_video_histories.find(params[:log_id])
- if params[:total_duration] < params[:watch_duration]
- return watch_video_history
- end
+ # if params[:total_duration] < params[:watch_duration]
+ # return watch_video_history
+ # end
# 更新观看时长
- if watch_video_history.present? && !watch_video_history.is_finished && watch_video_history.watch_duration <= params[:watch_duration] && watch_video_history.total_duration <= params[:total_duration]
+ if watch_video_history.present? && !watch_video_history.is_finished && watch_video_history.total_duration <= params[:total_duration]
# 如果观看总时长没变,说明视频没有播放,无需再去记录
watch_video_history.end_at = current_time
watch_video_history.total_duration = params[:total_duration]
watch_video_history.watch_duration = params[:watch_duration] > watch_video_history.duration ? watch_video_history.duration : params[:watch_duration]
watch_video_history.is_finished = params[:ed].present?
+ watch_video_history.last_point = params[:point].to_i
watch_video_history.save!
watch_course_video = watch_video_history.watch_course_video
@@ -33,10 +34,29 @@ class CreateWatchVideoService < ApplicationService
if watch_course_video.present?
watch_course_video.total_duration = watch_course_video.watch_video_histories.sum(:total_duration)
watch_course_video.end_at = current_time
+
+ if params[:point].to_i > watch_course_video.last_point
+ detail = WatchCourseVideoDetail.find_or_initialize_by(watch_course_video_id: watch_course_video.id, user_id: user.id) do |d|
+ d.times = [[ watch_course_video.last_point, params[:point].to_i]]
+ end
+ if detail.persisted?
+ detail.times << [watch_course_video.last_point, params[:point].to_i]
+ end
+ detail.save
+ end
+ watch_course_video.last_point = params[:point].to_i
+
if !watch_course_video.is_finished
# 更新课程视频的时长及是否看完状态
watch_course_video.watch_duration = params[:watch_duration] if watch_course_video.watch_duration < params[:watch_duration]
- watch_course_video.is_finished = watch_course_video.total_duration >= watch_course_video.duration if params[:ed].present?
+ if params[:ed].present? || (watch_course_video.duration >= 300 && (watch_course_video.duration - params[:point].to_i) <= 20)
+ video_duration = watch_video_history.video.duration.to_i
+ if video_duration > 0
+ watch_course_video.is_finished = watch_course_video.total_duration.to_i >= video_duration
+ else
+ watch_course_video.is_finished = watch_course_video.total_duration.to_i >= watch_course_video.duration.to_i
+ end
+ end
end
watch_course_video.save!
end
@@ -50,8 +70,8 @@ class CreateWatchVideoService < ApplicationService
d.start_at = current_time
d.duration = params[:duration]
end
-
- watch_course_video.save! unless watch_course_video.persisted?
+ watch_course_video.last_point = params[:point].to_i
+ watch_course_video.save!
watch_video_history = build_video_log(current_time, course_video.video_id, watch_course_video.id)
watch_video_history.save!
else
diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb
index 5483eed83..b161be991 100644
--- a/app/services/homeworks_service.rb
+++ b/app/services/homeworks_service.rb
@@ -133,9 +133,9 @@ class HomeworksService
# 计算实训作品学生的效率分
def update_student_eff_score homework
if homework.work_efficiency && homework.max_efficiency != 0
- max_efficiency = homework.student_works.where("compelete_status != 0").pluck(:efficiency).max
+ max_efficiency = homework.student_works.where("compelete_status > 0").pluck(:efficiency).max
homework.update_column("max_efficiency", max_efficiency)
- homework.student_works.where("compelete_status != 0").each do |student_work|
+ homework.student_works.where("compelete_status > 0").each do |student_work|
eff_score = student_work.efficiency / max_efficiency * homework.eff_score
student_work.eff_score = format("%.2f", eff_score)
student_work.late_penalty = student_work.work_status == 1 ? 0 : homework.late_penalty
@@ -146,7 +146,7 @@ class HomeworksService
student_work.save!
end
else
- homework.student_works.where("compelete_status != 0").each do |student_work|
+ homework.student_works.where("compelete_status > 0").each do |student_work|
student_work.eff_score = 0
student_work.late_penalty = student_work.work_status == 1 ? 0 : homework.late_penalty
unless student_work.ultimate_score
diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb
index 553ffe4f2..3ddc54967 100644
--- a/app/services/videos/batch_publish_service.rb
+++ b/app/services/videos/batch_publish_service.rb
@@ -31,16 +31,23 @@ class Videos::BatchPublishService < ApplicationService
# 非MP4 H264编码的都转码
code_info = AliyunVod::Service.get_meta_code_info(video.uuid)
+
+ result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
Rails.logger.info("code_info: #{code_info[:format]}, #{code_info[:codecnamne]}")
if code_info[:format] == "mp4" && code_info[:codecnamne].present? && code_info[:codecnamne].start_with?('h264')
video.transcoded = true
- result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
- play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL'] if result.present?
- video.play_url = play_url
+ if result.present? && result['PlayInfoList']['PlayInfo'].first['PlayURL']
+ play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL']
+ video.play_url = play_url
+ end
else
AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID)
end
+ if result.present?
+ video.duration = result['PlayInfoList']['PlayInfo'][0]['Duration'] if result['PlayInfoList']['PlayInfo'][0]['Duration'].present?
+ end
+
video.save!
if param[:course_id].present?
diff --git a/app/views/homework_commons/get_next_work.json.jbuilder b/app/views/homework_commons/get_next_work.json.jbuilder
new file mode 100644
index 000000000..e03b18970
--- /dev/null
+++ b/app/views/homework_commons/get_next_work.json.jbuilder
@@ -0,0 +1,2 @@
+json.work_id @work&.id
+json.user_name @work&.user&.real_name
\ No newline at end of file
diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder
index 7c51432d0..e261406c2 100644
--- a/app/views/homework_commons/works_list.json.jbuilder
+++ b/app/views/homework_commons/works_list.json.jbuilder
@@ -103,6 +103,7 @@ if @homework.homework_type == "practice"
json.efficiency work_score_format(work.efficiency, @current_user == work.user, @score_open)
json.eff_score work_score_format(work.eff_score, @current_user == work.user, @score_open)
+ json.myshixun_identifier work.myshixun&.identifier
json.cost_time work.myshixun.try(:total_spend_time)
json.current_complete_count myshixun.try(:passed_count) if @homework.end_or_late
end_time = @homework.allow_late ? @homework.late_time : @homework.homework_group_setting(work.user_id)&.end_time
@@ -114,7 +115,7 @@ if @homework.homework_type == "practice"
json.student_id work.user.try(:student_id)
json.group_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name)
json.work_status work.compelete_status
- json.has_comment work.shixun_work_comments.size > 0
+ json.has_comment work.shixun_has_comment?
end
elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.anonymous_comment @homework.anonymous_comment
@@ -175,7 +176,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.user_login @is_evaluation ? "--" : work.user.try(:login)
json.user_name @is_evaluation ? "匿名" : work.user.try(:real_name)
json.user_img @is_evaluation ? "--" : url_to_avatar(work.user)
-
+ json.has_comment work.work_has_comment?
end
end
diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder
index adf0a2ea5..c6596d1ee 100644
--- a/app/views/student_works/shixun_work_report.json.jbuilder
+++ b/app/views/student_works/shixun_work_report.json.jbuilder
@@ -1,4 +1,5 @@
json.homework_common_id @homework.id
+json.course_id @homework.course_id
json.category @homework.category_info
json.course_name @course.name
json.work_id @work.id
@@ -88,5 +89,8 @@ if @shixun
end
json.view_tpi @view_tpi
+json.myshixun_id @work.myshixun_id
+json.myshixun_identifier @work.myshixun&.identifier
+json.homework_end @homework.end_or_late
diff --git a/app/views/weapps/courses/show.json.jbuilder b/app/views/weapps/courses/show.json.jbuilder
index c22b24426..cf58315b4 100644
--- a/app/views/weapps/courses/show.json.jbuilder
+++ b/app/views/weapps/courses/show.json.jbuilder
@@ -1,4 +1,5 @@
json.(@course, :id, :name, :course_members_count, :credit, :invite_code_halt)
json.teachers_count @course.teachers.count
json.students_count @course.students.count
-json.course_identity @current_user.course_identity(@course)
\ No newline at end of file
+json.course_identity @current_user.course_identity(@course)
+json.teacher_users @teacher_users
\ No newline at end of file
diff --git a/app/views/weapps/homes/show.json.jbuilder b/app/views/weapps/homes/show.json.jbuilder
index f307d64fe..5d0e35e05 100644
--- a/app/views/weapps/homes/show.json.jbuilder
+++ b/app/views/weapps/homes/show.json.jbuilder
@@ -26,5 +26,6 @@ json.courses @courses.each do |course|
course_member = @category == "study" ? course.students.where(user_id: @user.id).first : course.teachers.where(user_id: @user.id).first
json.sticky course_member.sticky
json.course_identity current_user.course_identity(course)
+ json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师
end
diff --git a/config/routes.rb b/config/routes.rb
index 047141ea8..da07c8d89 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -597,6 +597,7 @@ Rails.application.routes.draw do
get :update_score
get :update_student_score
post :batch_comment
+ get :get_next_work
end
collection do
diff --git a/config/schedule.yml b/config/schedule.yml
new file mode 100644
index 000000000..cf5b7618f
--- /dev/null
+++ b/config/schedule.yml
@@ -0,0 +1,3 @@
+delete_unpublish_video_job:
+ cron: "0 24 * * *"
+ class: "DeleteUnpublishVideoJob"
\ No newline at end of file
diff --git a/db/migrate/20200318041550_create_watch_course_video_details.rb b/db/migrate/20200318041550_create_watch_course_video_details.rb
new file mode 100644
index 000000000..07984cb42
--- /dev/null
+++ b/db/migrate/20200318041550_create_watch_course_video_details.rb
@@ -0,0 +1,14 @@
+class CreateWatchCourseVideoDetails < ActiveRecord::Migration[5.2]
+ def change
+ create_table :watch_course_video_details do |t|
+ t.references :user, index: true
+ t.text :times
+ t.references :watch_course_video, index: true
+
+ t.timestamps
+ end
+
+ add_column :watch_course_videos, :last_point, :integer, default: 0
+ add_column :watch_video_histories, :last_point, :integer, default: 0
+ end
+end
diff --git a/db/migrate/20200318181442_add_duration_to_video.rb b/db/migrate/20200318181442_add_duration_to_video.rb
new file mode 100644
index 000000000..caf3a70e9
--- /dev/null
+++ b/db/migrate/20200318181442_add_duration_to_video.rb
@@ -0,0 +1,5 @@
+class AddDurationToVideo < ActiveRecord::Migration[5.2]
+ def change
+ add_column :videos, :duration, :float, default: 0
+ end
+end
diff --git a/lib/tasks/competition_extra_course_statistic.rake b/lib/tasks/competition_extra_course_statistic.rake
index a3e4f4f91..3ef6bcd18 100644
--- a/lib/tasks/competition_extra_course_statistic.rake
+++ b/lib/tasks/competition_extra_course_statistic.rake
@@ -12,7 +12,7 @@ namespace :competition do
student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql
subquery = StudentWork.where('homework_common_id = hcs.id')
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
shixun_user_ids = Shixun.where.not(user_id: old_competition_user_ids).where(status: 2).where('shixuns.created_at > ? && shixuns.created_at <= ?', start_time, end_time).pluck(:user_id).uniq
course_user_ids = Course.where.not(tea_id: old_competition_user_ids).where('courses.created_at > ?', start_time)
@@ -109,7 +109,7 @@ namespace :competition do
# =========== Course ===========
student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql
subquery = StudentWork.where('homework_common_id = hcs.id')
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
course_ids = Course.where('courses.created_at > ?', start_time)
.where('courses.created_at <= ?', end_time)
@@ -173,7 +173,7 @@ namespace :competition do
def get_valid_course_count(ids, end_time)
percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < ?', end_time)
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
Course.joins(practice_homeworks: :homework_commons_shixun)
@@ -184,7 +184,7 @@ namespace :competition do
def get_valid_shixun_count(ids, end_time)
percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < ?', end_time)
- .select('sum(compelete_status !=0 ) as finish, count(*) as total')
+ .select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
Shixun.joins(homework_commons_shixuns: :homework_common)
.where(homework_commons: { homework_type: 4 })
diff --git a/lib/tasks/get_video_data.rake b/lib/tasks/get_video_data.rake
index f6f85c7d5..efb89e99e 100644
--- a/lib/tasks/get_video_data.rake
+++ b/lib/tasks/get_video_data.rake
@@ -74,4 +74,17 @@ namespace :video do
end
end
end
+
+
+ task :set_duration => :environment do
+ videos = Video.published.where("duration = 0")
+ videos.find_each do |v|
+ result = AliyunVod::Service.get_play_info(v.uuid)
+ if result.present? && result['PlayInfoList']['PlayInfo'][0]['Duration'].present?
+ p "-----#{v.id} , #{result['PlayInfoList']['PlayInfo'][0]['Duration']}"
+ v.update(duration: result['PlayInfoList']['PlayInfo'][0]['Duration'])
+ end
+ end
+
+ end
end
\ No newline at end of file
diff --git a/lib/tasks/sync_video.rake b/lib/tasks/sync_video.rake
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/react/src/common/DateUtil.js b/public/react/src/common/DateUtil.js
index 4bc481b10..859182e18 100644
--- a/public/react/src/common/DateUtil.js
+++ b/public/react/src/common/DateUtil.js
@@ -96,4 +96,4 @@ export function formatDuring(mss){
}
return days + "天" + hours + "小时" + minutes + "分";
-}
\ No newline at end of file
+}
diff --git a/public/react/src/modules/courses/Video/VideoIndex.js b/public/react/src/modules/courses/Video/VideoIndex.js
index 4b8cab735..0815bc8aa 100644
--- a/public/react/src/modules/courses/Video/VideoIndex.js
+++ b/public/react/src/modules/courses/Video/VideoIndex.js
@@ -361,10 +361,11 @@ class VideoIndex extends Component {
{
videoId ?
""
- :
+ :videos&&videos.length>0?