|
|
|
@ -30,7 +30,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
:informs, :update_informs, :online_learning, :update_task_position, :tasks_list,
|
|
|
|
|
:join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs,
|
|
|
|
|
:delete_informs, :change_member_role, :course_groups, :join_course_group, :statistics,
|
|
|
|
|
:work_score, :act_score, :calculate_all_shixun_scores, :move_to_category]
|
|
|
|
|
:work_score, :act_score, :calculate_all_shixun_scores, :move_to_category, :watch_video_histories]
|
|
|
|
|
before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course,
|
|
|
|
|
:search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list]
|
|
|
|
|
before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate,
|
|
|
|
@ -114,7 +114,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
#sql = "left join videos on videos.id=course_videos.video_id AND (videos.transcoded=1 OR videos.user_id = #{current_user.id})"
|
|
|
|
|
#@videos = paginate videos.joins(sql).includes(video: [user: :user_extension], user: :user_extension)
|
|
|
|
|
videos = videos.includes(video: [user: :user_extension], user: :user_extension)
|
|
|
|
|
videos = videos.includes(:watch_course_videos, video: [user: :user_extension],user: :user_extension)
|
|
|
|
|
videos = videos.where(videos: {transcoded: true})
|
|
|
|
|
.or(videos.where(videos: {user_id: current_user.id}))
|
|
|
|
|
.or(videos.where(course_videos: {is_link: true}))
|
|
|
|
@ -1481,6 +1481,23 @@ class CoursesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def watch_video_histories
|
|
|
|
|
@videos = CourseVideo.find_by_sql("
|
|
|
|
|
SELECT course_videos.id, videos.user_id, videos.title, IFNULL(hisotries.time,0) AS time, IFNULL(hisotries.num,0) AS num
|
|
|
|
|
FROM course_videos
|
|
|
|
|
JOIN videos ON course_videos.course_id = #{@course.id} AND videos.id = course_videos.video_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT watch_course_videos.course_video_id, sum(watch_course_videos.total_duration) AS time, count(watch_course_videos.course_video_id) AS num
|
|
|
|
|
FROM watch_course_videos
|
|
|
|
|
JOIN course_videos ON course_videos.id = watch_course_videos.course_video_id
|
|
|
|
|
WHERE course_videos.course_id = #{@course.id}
|
|
|
|
|
GROUP BY watch_course_videos.course_video_id
|
|
|
|
|
) AS hisotries ON hisotries.course_video_id = course_videos.id
|
|
|
|
|
")
|
|
|
|
|
@count = @videos.count
|
|
|
|
|
@videos = paginate @videos
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
|
|
|