Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into courseware

courseware
杨树林 5 years ago
commit 0edc0fae63

@ -26,14 +26,13 @@ class CourseVideosController < ApplicationController
@watch_course_videos = course_video.watch_course_videos.joins("
JOIN watch_video_histories ON watch_video_histories.watch_course_video_id = watch_course_videos.id
JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id} AND role = 4
").group("watch_video_histories.watch_course_video_id").where("watch_course_videos.end_at IS NOT NULL").select("watch_course_videos.id")
@count = @watch_course_videos.count.count
if params[:group_id].present?
@watch_course_videos = @watch_course_videos.joins("
JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id}
").where("course_members.course_group_id = ?", params[:group_id])
@watch_course_videos = @watch_course_videos.where("course_members.course_group_id = ?", params[:group_id])
end
@watch_course_videos = @watch_course_videos.select("count(watch_video_histories.id) AS freq, watch_course_videos.*")

@ -1494,6 +1494,7 @@ class CoursesController < ApplicationController
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 AND watch_course_videos.end_at IS NOT NULL
JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id} AND role = 4
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").select("course_videos.id")
@ -1523,6 +1524,7 @@ class CoursesController < ApplicationController
SELECT watch_course_videos.course_video_id, 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
JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id} AND role = 4
WHERE course_videos.course_id = #{@course.id} AND watch_course_videos.user_id = #{current_user.id} AND watch_course_videos.end_at IS NOT NULL
GROUP BY watch_course_videos.course_video_id
) AS hisotries ON hisotries.course_video_id = course_videos.id").select("course_videos.id")
@ -1543,9 +1545,12 @@ class CoursesController < ApplicationController
# 课堂视频的统计总览
def watch_statics
@total_duration = @course.course_videos.joins(:watch_course_videos).sum(:total_duration).round(2)
@frequencies = @course.course_videos.joins([watch_course_videos: :watch_video_histories]).count(:id)
@people_num = @course.course_videos.joins(:watch_course_videos).count(:id)
course_videos = @course.course_videos.joins(:watch_course_videos).joins("
JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id} AND role = 4
")
@total_duration = course_videos.sum(:total_duration).round(0)
@frequencies = course_videos.joins("JOIN watch_video_histories ON watch_course_videos.id = watch_video_histories.watch_course_video_id").count(:id)
@people_num = course_videos.count(:id)
render json: {
total_duration: @total_duration,
freq: @frequencies,

@ -2,7 +2,7 @@ json.data do
json.array! @watch_course_videos do |d|
json.user_name d.user&.real_name
json.is_finished d.is_finished ? true : false
json.total_duration d.total_duration.round(2)
json.total_duration d.total_duration.round(0)
json.feq d['freq']
json.start_at d.start_at.to_s
json.end_at d.end_at.to_s

@ -3,7 +3,7 @@ json.data do
json.title d.title
json.user_name @current_user&.real_name
json.is_finished d.is_finished ? true : false
json.total_duration d.total_duration.round(2)
json.total_duration d.total_duration.round(0)
json.freq d['freq']
json.start_at d.start_at.to_s
json.end_at d.end_at.to_s

@ -4,7 +4,7 @@ json.videos do
json.title v.title
json.user_name v.user&.real_name
json.people_num v['people_num']
json.total_time v['total_time']
json.total_time v['total_time'].round(0)
end
end
json.count @count

@ -382,7 +382,7 @@ class VideoIndex extends Component {
isAdmin?
<Videostatistics {...this.props} {...this.state} statisticsy={(b) => this.statisticsy(b)}></Videostatistics>
:
<Videostatisticscomtwo {...this.props} {...this.state} ></Videostatisticscomtwo>
<Videostatisticscomtwo {...this.props} {...this.state} mytitle={""} ></Videostatisticscomtwo>
)
}
{

@ -14,6 +14,7 @@ class Videostatistics extends Component{
watch_staticsdata:[],
tisticsbool:false,
tisid:null,
mytitle:""
}
@ -43,16 +44,17 @@ class Videostatistics extends Component{
});
}
tisticsbools=(bool,id)=>{
tisticsbools=(bool,id,mytitle)=>{
this.setState({
tisticsbool:bool,
tisid:id,
mytitle:mytitle
})
}
render(){
let {watch_staticsdata,tisticsbool,tisid}= this.state;
let {watch_staticsdata,tisticsbool,tisid,mytitle}= this.state;
return(
<React.Fragment>
@ -79,13 +81,13 @@ class Videostatistics extends Component{
<div>
<Videostatisticslist {...this.state} {...this.props} tisticsbools={(b,id)=>this.tisticsbools(b,id)}></Videostatisticslist>
<Videostatisticslist {...this.state} {...this.props} tisticsbools={(b,id,t)=>this.tisticsbools(b,id,t)}></Videostatisticslist>
</div>
</div>
:
<Videostatisticscomtwo {...this.state} {...this.props} tisid={tisid} tisticsbools={(b,id)=>this.tisticsbools(b,id)}></Videostatisticscomtwo>
<Videostatisticscomtwo {...this.state} {...this.props} tisid={tisid} mytitle={mytitle} tisticsbools={(b,id,t)=>this.tisticsbools(b,id,t)}></Videostatisticscomtwo>
}
</div>

@ -207,6 +207,7 @@ class Videostatisticscomtwo extends Component {
feq: response.data.data[i].feq,
start_at: response.data.data[i].start_at,
end_at: response.data.data[i].end_at,
title: response.data.data[i].title,
})
}
@ -436,12 +437,21 @@ class Videostatisticscomtwo extends Component {
}
</Menu>
);
let mytitle="";
if(isAdmin){
mytitle=this.props&&this.props.mytitle;
}else{
mytitle=this.state.data[0].title;
}
return (
<React.Fragment>
<div className="ws100s">
<div className="ws100s teacherentrydivss edu-back-white ">
<div className="ws100s sortinxdirection">
<div className="ws50s sptits">视频名称视频名称</div>
<div className="ws50s sptits">{mytitle}</div>
<div className="ws50s sptitss xaxisreverseorder font-14" style={{
color: "#5091FF",
lineHeight: "42px",
@ -463,9 +473,9 @@ class Videostatisticscomtwo extends Component {
<span className="mr5 xiaoshou">分班</span>
{
fbbool === true ?
<i className="iconfont icon-sanjiaoxing-down font-13 mr32 xiaoshou"></i>
<i className="iconfont icon-sanjiaoxing-up font-13 mr32 xiaoshou"></i>
:
<i className="iconfont icon-sanjiaoxing-up font-13 mr32 xiaoshou"></i>
<i className="iconfont icon-sanjiaoxing-down font-13 mr32 xiaoshou"></i>
}
</span>
</Dropdown>
@ -488,7 +498,7 @@ class Videostatisticscomtwo extends Component {
}
</style>
<div className="ws100s ysltableo mt10">
<div className="ws100s ysltableo mt10" style={{ minHeight: "400px"}}>
{
data.length === 0 ?
<div style={{

@ -97,7 +97,7 @@ class Videostatisticslist extends Component {
className: 'font-14',
width: '50px',
render: (text, record) => (
<span style={{width: '50px',color:'#5091FF'}} className="xiaoshou" onClick={()=>this.props.tisticsbools(true,record.id)}>详情</span>
<span style={{width: '50px',color:'#5091FF'}} className="xiaoshou" onClick={()=>this.props.tisticsbools(true,record.id,record.title)}>详情</span>
),
}
],
@ -266,7 +266,7 @@ class Videostatisticslist extends Component {
}
</style>
<div className="ws100s ysltableo teacherentrydivs pdinstop0">
<div className="ws100s ysltableo teacherentrydivs pdinstop0" style={{ minHeight: "400px"}}>
{
data.length===0?
<div style={{

Loading…
Cancel
Save