Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

courseware
杨树明 5 years ago
commit 41ba9ee146

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

@ -99,7 +99,7 @@ class CoursesController < ApplicationController
limit = params[:limit] || 16
@courses = @courses.page(page).per(limit)
@courses = @courses.preload(:school, :none_hidden_course_modules, teacher: :user_extension)
@courses = @courses.preload(:school, :none_hidden_course_modules, :teacher_users, teacher: :user_extension)
end
def course_videos

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

@ -28,7 +28,7 @@ class MyshixunsController < ApplicationController
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, cost_time: 0, compelete_status: -1)
end
# 删除版本库
GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type?

@ -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 = "未通关"

@ -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
# 作品状态

@ -223,6 +223,11 @@ 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 scored?
student_works_scores.where.not(reviewer_role: 3, score: nil).exists?
end

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

@ -13,5 +13,6 @@ json.courses @courses do |course|
json.is_end course.is_end
json.first_category_url module_url(course.none_hidden_course_modules.first, course)
json.excellent course.excellent
json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师
end
json.courses_count @courses_count

@ -114,7 +114,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

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

@ -3,7 +3,8 @@ namespace :video_transcode do
desc "视频转码成h264"
task :submit => :environment do
i = []
Video.where.not(uuid: nil, file_url: nil).where(transcoded: false).find_each do |v|
Video.where(transcoded: false).find_each do |v|
if v.uuid.present? && v.file_url.present?
code_info = AliyunVod::Service.get_meta_code_info(v.uuid)
if v.file_url.include?('.mp4') && code_info[:codecnamne]&.include?("h264")
v.update(transcoded: true)
@ -12,9 +13,12 @@ namespace :video_transcode do
i << "#{v.id}, #{v.file_url}, #{code_info[:codecnamne]}"
AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') rescue nil
end
else
v.update_column(:transcoded, true)
end
end
puts "###########转码个数:#{i.size}"
puts "###########id,file_url, codecnamne:#{i}"
Video.where(transcoded: false).update_all(transcoded: true)
#Video.where(transcoded: false).update_all(transcoded: true)
end
end
Loading…
Cancel
Save