Merge branches 'dev_aliyun' and 'develop' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
杨树明 5 years ago
commit 1dd36b10b5

@ -90,6 +90,7 @@ gem 'rails-i18n', '~> 5.1'
# job
gem 'sidekiq'
gem 'sinatra'
gem "sidekiq-cron", "~> 1.1"
# batch insert
gem 'bulk_insert'

@ -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"]

@ -13,7 +13,7 @@ class Admins::CoursesController < Admins::BaseController
format.js
format.html
format.xlsx do
@courses = courses.includes(:school, :students, :teacher_course_members, :informs, :course_videos, :attachments, :homework_commons, :course_activities, teacher: [user_extension: :department])
@courses = courses.not_deleted.includes(:school, :students, :teacher_course_members, :informs, :course_videos, :attachments, :homework_commons, :course_activities, teacher: [user_extension: :department])
filename = "课堂列表_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx"
render xlsx: 'index', filename: filename
end

@ -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")

@ -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

@ -228,6 +228,11 @@ class StudentWork < ApplicationRecord
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

@ -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)

@ -3,7 +3,7 @@ wb = xlsx_package.workbook
wb.styles do |s|
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
wb.add_worksheet(name: "课堂列表") do |sheet|
sheet.add_row %w(ID 课堂名称 老师 学生 资源 公告 视频 普通作业 分组作业 实训作业 实训作业已发布数 作品数 试卷 评测次数 私有 状态 单位 部门 创建者 创建时间 动态时间), :height => 25,:style => blue_cell
sheet.add_row %w(ID 课堂名称 老师 学生 分班数 资源 公告 视频 普通作业 分组作业 实训作业 实训作业已发布数 作品数 试卷 评测次数 私有 状态 单位 部门 创建者 创建时间 动态时间), :height => 25,:style => blue_cell
@courses.each do |course|
data = [
@ -11,6 +11,7 @@ wb.styles do |s|
course.name,
course.teacher_course_members.size,
course.students.size,
course.course_groups_count,
get_attachment_count(course, 0),
course.informs.size,
course.course_videos.size,

@ -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
@ -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

@ -88,5 +88,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

@ -1,3 +1,5 @@
require 'sidekiq/web'
require 'sidekiq/cron/web'
redis_config = Rails.application.config_for(:redis)
sidekiq_url = redis_config["url"]
@ -8,3 +10,9 @@ end
Sidekiq.configure_client do |config|
config.redis = { url: sidekiq_url }
end
schedule_file = "config/schedule.yml"
if File.exists?(schedule_file) && Sidekiq.server?
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
end

@ -0,0 +1,3 @@
delete_unpublish_video_job:
cron: "0 24 * * *"
class: "DeleteUnpublishVideoJob"

@ -96,4 +96,4 @@ export function formatDuring(mss){
}
return days + "天" + hours + "小时" + minutes + "分";
}
}

@ -549,3 +549,6 @@
.widh150wpos{
word-break: break-all;
}
a { text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}

@ -87,6 +87,16 @@ class Videostatistics extends Component{
return(
<React.Fragment>
<div className="ws100s">
<script>
{
`
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
{
tisticsbool===false?
<div className="ws100s" style={{

@ -36,14 +36,9 @@ class Studenticscom extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;//鼠标放上面不显示下划线
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>

@ -38,18 +38,13 @@ class Studentstatistics extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth150s textalignlefts" style={{
<a className="maxnamewidth150s textalignlefts xiaoshout" style={{
color:"#333333"
}} title={record.title}>{record.title}</a>
@ -83,18 +78,13 @@ class Studentstatistics extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth100s " style={{
<a className="maxnamewidth100s xiaoshout" style={{
color:"#333333"
}} title={record.total_duration}>{record.total_duration}</a>
@ -113,18 +103,13 @@ class Studentstatistics extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth100s" style={{
<a className="maxnamewidth100s xiaoshout" style={{
color:"#333333"
}} title={record.user_name}>{record.user_name}</a>
@ -297,14 +282,9 @@ class Studentstatistics extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;//鼠标放上面不显示下划线
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>

@ -36,14 +36,9 @@ class Videostatisticscom extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;//鼠标放上面不显示下划线
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>

@ -43,18 +43,13 @@ class Videostatisticscomtwo extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth100s" style={{
<a className="maxnamewidth100s xiaoshout" style={{
color:"#333333"
}} title={record.user_name}>{record.user_name}</a>
@ -87,18 +82,13 @@ class Videostatisticscomtwo extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth100s" style={{
<a className="maxnamewidth100s xiaoshout" style={{
color:"#333333"
}} title={record.total_duration}>{record.total_duration}</a></div>
),
@ -117,18 +107,13 @@ class Videostatisticscomtwo extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth100s" style={{
<a className="maxnamewidth100s xiaoshout" style={{
color:"#333333"
}} title={record.feq}>{record.feq}</a>
</div>
@ -145,20 +130,15 @@ class Videostatisticscomtwo extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
{
record.start_at?
<a style={{
<a className="xiaoshout" style={{
color:"#333333"
}} title={moment(record.start_at).format('YYYY-MM-DD HH:mm:ss')}>{moment(record.start_at).format('YYYY-MM-DD HH:mm:ss')}</a>
:
@ -178,20 +158,15 @@ class Videostatisticscomtwo extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
{
record.end_at?
<a style={{
<a className="xiaoshout" style={{
color:"#333333"
}} title={moment(record.end_at).format('YYYY-MM-DD HH:mm:ss')}>{moment(record.end_at).format('YYYY-MM-DD HH:mm:ss')}</a>
:
@ -559,14 +534,11 @@ class Videostatisticscomtwo extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;//鼠标放上面不显示下划线
    color:#333;
a{ 
    text-decoration:none !important;
}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>

@ -38,18 +38,13 @@ class Videostatisticslist extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth200ss textalignlefts" style={{
<a className="maxnamewidth200ss textalignlefts xiaoshout" style={{
color:"#333333"
}} title={record.title}>{record.title}</a>
@ -83,18 +78,13 @@ class Videostatisticslist extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth100s " style={{
<a className="maxnamewidth100s xiaoshout" style={{
color:"#333333"
}} title={record.total_time}>{record.total_time}</a>
@ -113,18 +103,13 @@ class Videostatisticslist extends Component {
<script>
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;
    color:#333;
}
a{text-decoration:none !important;}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>
<a className="maxnamewidth150ss" style={{
<a className="maxnamewidth150ss xiaoshout" style={{
color:"#333333"
}} title={record.user_name}>{record.user_name}</a>
@ -294,13 +279,10 @@ class Videostatisticslist extends Component {
{
`
a{ 
    text-decoration:none;
    color:#333;
}
a:hover{
    text-decoration:none;//鼠标放上面不显示下划线
    color:#333;
    text-decoration:none !important;
}
a:hover {text-decoration: none !important;}
a:active{text-decoration:none !important;}
`
}
</script>

Loading…
Cancel
Save