From 0e025048c193fdf7776b5e9e9bb54239c1fda6ee Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 22 Aug 2019 16:25:54 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/excellent_course_exercise.rake | 20 +++++++++++--------- lib/tasks/public_course.rake | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index 0d8875806..a7fac1a8f 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -14,16 +14,18 @@ namespace :excellent_course_exercise do course = Course.find_by(id: course_id) course.exercises.each_with_index do |exercise, index| - # 第一个试卷的参与人数和通过人数都是传的数据,后续的随机 - if index == 0 - members = course.students.order("id asc").limit(participant_count) - update_exercise_user(exercise, members, pass_count) - else - new_participant_count = rand((participant_count - 423)..participant_count) - new_pass_count = rand((new_participant_count - 113)..new_participant_count) + if exercise.exercise_users.where(commit_status: 1).count == 0 + # 第一个试卷的参与人数和通过人数都是传的数据,后续的随机 + if index == 0 + members = course.students.order("id asc").limit(participant_count) + update_exercise_user(exercise, members, pass_count) + else + new_participant_count = rand((participant_count - 423)..participant_count) + new_pass_count = rand((new_participant_count - 113)..new_participant_count) - members = course.students.order("id asc").limit(new_participant_count) - update_exercise_user(exercise, members, new_pass_count) + members = course.students.order("id asc").limit(new_participant_count) + update_exercise_user(exercise, members, new_pass_count) + end end end end diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index ff50a4e28..5e56926b3 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -110,6 +110,23 @@ namespace :public_course do 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) puts time return time < 9 ? "0#{time}" : time From 4a4a00c24e3f7c03511283a1e69744b87b0d0a1e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 22 Aug 2019 16:52:14 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20190822022306_add_exercise_user_update.rb | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/db/migrate/20190822022306_add_exercise_user_update.rb b/db/migrate/20190822022306_add_exercise_user_update.rb index 059553306..223ee520b 100644 --- a/db/migrate/20190822022306_add_exercise_user_update.rb +++ b/db/migrate/20190822022306_add_exercise_user_update.rb @@ -1,19 +1,19 @@ class AddExerciseUserUpdate < ActiveRecord::Migration[5.2] include ExercisesHelper def change - exs = Exercise.all.is_exercise_published.where("publish_time > ?",(Time.now - 2.months)).includes(:exercise_questions,:exercise_users) - 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)) - if ex_users.present? - ex_users.each do |ex_user| - calculate_score = calculate_student_score(ex,ex_user.user)[:total_score] - subjective_score = ex_user.subjective_score - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = calculate_score + total_score_subjective_score - ex_user.update_attributes(score:total_score,objective_score:calculate_score) - puts ex_user.id - end - end - end + # exs = Exercise.all.is_exercise_published.where("publish_time > ?",(Time.now - 2.months)).includes(:exercise_questions,:exercise_users) + # 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)) + # if ex_users.present? + # ex_users.each do |ex_user| + # calculate_score = calculate_student_score(ex,ex_user.user)[:total_score] + # subjective_score = ex_user.subjective_score + # total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score + # total_score = calculate_score + total_score_subjective_score + # ex_user.update_attributes(score:total_score,objective_score:calculate_score) + # puts ex_user.id + # end + # end + # end end end From 7ea41bf4968af5f8fbe63d6afba1973ccf010524 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 22 Aug 2019 19:26:34 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 4cf6aa15a..470315bdc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -28,7 +28,7 @@ class CoursesController < ApplicationController :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_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, - :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, :transfer_to_course_group, :delete_from_course, :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher] From 2ddbbebaf2ec294f113630958b4f56bff095f6b2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 22 Aug 2019 19:33:02 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BD=9C=E5=93=81=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/public_course.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index 5e56926b3..d4f62a6e0 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -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.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 when 3 # 试卷 From c69f7bb2e310c8f0ec81dc440ef59f0d91b68b75 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 22 Aug 2019 20:22:04 +0800 Subject: [PATCH 5/8] tiaoz --- app/models/subject.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/subject.rb b/app/models/subject.rb index b8d6eef8b..836976418 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -19,7 +19,7 @@ class Subject < ApplicationRecord 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 :description, length: { maximum: 5000 } From a33c9e2442010a14339405a8fe44d314eeed079a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 23 Aug 2019 09:20:24 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_works/shixun_work.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/student_works/shixun_work.json.jbuilder b/app/views/student_works/shixun_work.json.jbuilder index 39e7eb1b3..1be74ea4c 100644 --- a/app/views/student_works/shixun_work.json.jbuilder +++ b/app/views/student_works/shixun_work.json.jbuilder @@ -11,8 +11,8 @@ json.image_url url_to_avatar(@work_user) json.complete_count @myshixun.passed_count json.challenges_count @shixun.challenges_count -json.efficiency number_with_precision @work.efficiency, precision: 2 -json.max_efficiency number_with_precision @homework.max_efficiency, precision: 2 +json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil +json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil json.passed_time @myshixun.passed_time json.total_spend_time @myshixun.total_spend_time json.user_score @myshixun.total_score From 672b8507631370af286efed0734db6e4664294ec Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 23 Aug 2019 09:34:55 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=BB=93=E6=9E=9C=E6=AD=A3=E7=A1=AE=E7=8E=87=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 58 ++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 7994e2c6a..2e327c86f 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -86,7 +86,7 @@ module ExercisesHelper #试卷的统计结果页面计算各题的 def exercise_commit_result(questions,user_ids) question_infos = [] - percent = 0.0 + # percent = 0.0 questions.includes(:exercise_choices).each do |ex| ex_total_score = user_ids.count * ex&.question_score.to_f #该试卷的已回答的总分 # ex_answers = ex.exercise_answers @@ -103,38 +103,42 @@ module ExercisesHelper end effictive_users_count = effictive_users.size #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数 + # + # if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时, + # ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 + # percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 + # end - if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时, - ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 - percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 - end + #全部题型按已提交学生的分数来计算 + ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 + percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 question_answer_infos = [] if ex.question_type <= Exercise::JUDGMENT #选择题和判断题 ex_choices = ex.exercise_choices standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置 - right_users_count = 0 + # right_users_count = 0 #该问题的正确率 - if ex.question_type == Exercise::MULTIPLE #多选题 - right_user_ids = user_ids - standard_answer.each do |choice_position| - standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id - right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) - end - right_users_count = right_user_ids.size - # user_ids.each do |user_id| - # ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq - # answer_choice_array = ex_choices.map{|a| a.choice_position if ex_choice_ids.include?(a.id)}.reject(&:blank?).uniq - # if answer_choice_array.sort == standard_answer - # right_users_count += 1 - # end - # end - else #单选题和判断题 - standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id - right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size - end - - percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0 + # if ex.question_type == Exercise::MULTIPLE #多选题 + # right_user_ids = user_ids + # standard_answer.each do |choice_position| + # standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == choice_position}.first&.id + # right_user_ids = right_user_ids & effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.pluck(:user_id) + # end + # right_users_count = right_user_ids.size + # # user_ids.each do |user_id| + # # ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq + # # answer_choice_array = ex_choices.map{|a| a.choice_position if ex_choice_ids.include?(a.id)}.reject(&:blank?).uniq + # # if answer_choice_array.sort == standard_answer + # # right_users_count += 1 + # # end + # # end + # else #单选题和判断题 + # standard_answer_choice_id = ex_choices.select{|ec| ec.choice_position == standard_answer.first}.first&.id + # right_users_count = effictive_users.select{|answer| answer.exercise_choice_id == standard_answer_choice_id}.size + # end + + # percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0 #每个选项的正确率 ex_choices.each do |c| @@ -180,7 +184,7 @@ module ExercisesHelper all_user_count += user_count standard_answer_count += 1 end - percent = effictive_users_count > 0 ? (all_user_count / effictive_users_count.to_f).round(3)*100 : 0.0 + # percent = effictive_users_count > 0 ? (all_user_count / effictive_users_count.to_f).round(3)*100 : 0.0 user_wrong_count = (effictive_users_count - all_user_count ) if effictive_users_count > 0 && user_wrong_count >= 0 From 55fcf27b961da0acd1be0a3907a7ef4e6452645a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 23 Aug 2019 09:35:51 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E9=80=89=E7=94=A8=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3a512278a..e3c55242f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -19,7 +19,7 @@ class Attachment < ApplicationRecord scope :contains_only_project, -> { where(container_type: 'Project') } scope :contains_course_and_project, -> { contains_only_course.or(contains_only_project) } scope :mine, -> (author_id) { where(author_id: author_id) } - scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id) } + scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type) } scope :search_by_container, -> (ids) {where(container_id: ids)} validates_length_of :description, maximum: 100