Merge branch 'develop' into dev_aliyun

dev_local_2
cxt 6 years ago
commit b6fdfe3aa0

@ -28,7 +28,7 @@ class CoursesController < ApplicationController
:switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course,
:informs, :update_informs, :online_learning, :update_task_position, :tasks_list, :join_excellent_course] :informs, :update_informs, :online_learning, :update_task_position, :tasks_list, :join_excellent_course]
before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course, 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] :search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list]
before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate,
:transfer_to_course_group, :delete_from_course, :transfer_to_course_group, :delete_from_course,
:search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher] :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher]

@ -19,7 +19,7 @@ class Subject < ApplicationRecord
has_many :stages, -> { order("stages.position ASC") }, dependent: :destroy has_many :stages, -> { order("stages.position ASC") }, dependent: :destroy
# 开放课堂 # 开放课堂
has_many :courses, -> { where("is_delete = 0").order("courses.id ASC") } has_many :courses, -> { where("is_delete = 0").order("courses.created_at ASC") }
validates :name, length: { maximum: 60 } validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 5000 } validates :description, length: { maximum: 5000 }

@ -11,8 +11,8 @@ json.image_url url_to_avatar(@work_user)
json.complete_count @myshixun.passed_count json.complete_count @myshixun.passed_count
json.challenges_count @shixun.challenges_count json.challenges_count @shixun.challenges_count
json.efficiency number_with_precision @work.efficiency, precision: 2 json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil
json.max_efficiency number_with_precision @homework.max_efficiency, precision: 2 json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil
json.passed_time @myshixun.passed_time json.passed_time @myshixun.passed_time
json.total_spend_time @myshixun.total_spend_time json.total_spend_time @myshixun.total_spend_time
json.user_score @myshixun.total_score json.user_score @myshixun.total_score

@ -1,20 +1,19 @@
class AddExerciseUserUpdate < ActiveRecord::Migration[5.2] class AddExerciseUserUpdate < ActiveRecord::Migration[5.2]
include ExercisesHelper include ExercisesHelper
def change def change
#2019,8,22添加 # exs = Exercise.all.is_exercise_published.where("publish_time > ?",(Time.now - 2.months)).includes(:exercise_questions,:exercise_users)
exs = Exercise.all.is_exercise_published.where("publish_time > ?",(Time.now - 2.months)).includes(:exercise_questions,:exercise_users) # exs.each do |ex|
exs.each do |ex| # ex_users = ex.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",(Time.now - 2.months))
ex_users = ex.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",(Time.now - 2.months)) # if ex_users.present?
if ex_users.present? # ex_users.each do |ex_user|
ex_users.each do |ex_user| # calculate_score = calculate_student_score(ex,ex_user.user)[:total_score]
calculate_score = calculate_student_score(ex,ex_user.user)[:total_score] # subjective_score = ex_user.subjective_score
subjective_score = ex_user.subjective_score # total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score # total_score = calculate_score + total_score_subjective_score
total_score = calculate_score + total_score_subjective_score # ex_user.update_attributes(score:total_score,objective_score:calculate_score)
ex_user.update_attributes(score:total_score,objective_score:calculate_score) # puts ex_user.id
puts ex_user.id # end
end # end
end # end
end
end end
end end

@ -14,6 +14,7 @@ namespace :excellent_course_exercise do
course = Course.find_by(id: course_id) course = Course.find_by(id: course_id)
course.exercises.each_with_index do |exercise, index| course.exercises.each_with_index do |exercise, index|
if exercise.exercise_users.where(commit_status: 1).count == 0
# 第一个试卷的参与人数和通过人数都是传的数据,后续的随机 # 第一个试卷的参与人数和通过人数都是传的数据,后续的随机
if index == 0 if index == 0
members = course.students.order("id asc").limit(participant_count) members = course.students.order("id asc").limit(participant_count)
@ -27,6 +28,7 @@ namespace :excellent_course_exercise do
end end
end end
end end
end
def update_exercise_user exercise, members, pass_count def update_exercise_user exercise, members, pass_count
exercise_question_ids = exercise.exercise_questions.where(question_type: 0).pluck(:id) exercise_question_ids = exercise.exercise_questions.where(question_type: 0).pluck(:id)

@ -88,6 +88,8 @@ namespace :public_course do
homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at) homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at)
homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at) homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at)
homework.student_works.where("work_status !=0 and update_time > '#{end_time}'").update_all(update_time: end_time)
end end
when 3 when 3
# 试卷 # 试卷
@ -110,6 +112,23 @@ namespace :public_course do
end end
task :create_homework_work => :environment do
course = Course.find(course_id)
course.practice_homeworks.each do |homework|
if homework.student_works.count == 0
str = ""
CourseMember.students(course).each do |student|
str += "," if str != ""
str += "(#{homework.id},#{student.user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into student_works (homework_common_id, user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
def min_swith(time) def min_swith(time)
puts time puts time
return time < 9 ? "0#{time}" : time return time < 9 ? "0#{time}" : time

Loading…
Cancel
Save