Merge branch 'dev_cxt' into dev_aliyun

dev_auth
cxt 6 years ago
commit 92246580cc

@ -1407,11 +1407,16 @@ class ExercisesController < ApplicationController
min_score = exercise_scores.min.present? ? exercise_scores.min : 0.0 min_score = exercise_scores.min.present? ? exercise_scores.min : 0.0
max_score = exercise_scores.max.present? ? exercise_scores.max : 0.0 max_score = exercise_scores.max.present? ? exercise_scores.max : 0.0
total_score = exercise_scores.sum.present? ? exercise_scores.sum : 0.0 total_score = exercise_scores.sum.present? ? exercise_scores.sum : 0.0
average_score = @exercise_commit_user_counts > 0 ? (total_score / @exercise_commit_user_counts).round(1) : 0.0 average_score = @exercise_commit_user_counts > 0 ? (total_score.round(1) / @exercise_commit_user_counts).round(1) : 0.0
fail_counts = exercise_scores.count{|a| a < 60.0} question_scores = @exercise.question_scores
pass_counts = exercise_scores.count{|a| a < 70.0 && a >= 60.0} fail_score = question_scores * 0.6.round(2)
good_counts = exercise_scores.count{|a| a < 90.0 && a >= 70.0} pass_score = question_scores * 0.7.round(2)
best_counts = exercise_scores.count{|a| a >= 90.0 && a <= 100.0} good_score = question_scores * 0.9.round(2)
fail_counts = exercise_scores.count{|a| a < fail_score}
pass_counts = exercise_scores.count{|a| a < pass_score && a >= fail_score}
good_counts = exercise_scores.count{|a| a < good_score && a >= pass_score}
best_counts = exercise_scores.count{|a| a >= good_score && a <= question_scores}
end end
@counts_array = { @counts_array = {
:commit_percent => commit_percent, :commit_percent => commit_percent,

@ -112,7 +112,7 @@ module ExportHelper
@work_cells_column.push(row_cells_column) @work_cells_column.push(row_cells_column)
end end
else #实训题 else #实训题
shixun = homework.shixuns.first shixun = homework.shixuns.take
shixun_head_cells = %w(完成情况 通关时间 学员在EduCoder做实训花费的时间 总评测次数 获得经验值 关卡得分) shixun_head_cells = %w(完成情况 通关时间 学员在EduCoder做实训花费的时间 总评测次数 获得经验值 关卡得分)
eff_boolean = homework.work_efficiency eff_boolean = homework.work_efficiency
if eff_boolean if eff_boolean
@ -123,9 +123,12 @@ module ExportHelper
if allow_late_boolean #允许迟交 if allow_late_boolean #允许迟交
eff_score_cell.push("迟交扣分") eff_score_cell.push("迟交扣分")
end end
shixun_time_cells = %w(最终成绩 更新时间 作业发布到学员完成作业所耗的时间 评语) shixun_time_cells = %w(最终成绩 更新时间 作业发布到学员完成作业所耗的时间 总评语)
for i in 1 .. shixun.challenges.size
shixun_time_cells << "#{i}关评语"
end
@work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?) @work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?)
works.includes(:student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index| works.includes(:shixun_work_comments, :student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index|
myshixun = w.try(:myshixun) myshixun = w.try(:myshixun)
w_user = w.user w_user = w.user
w_1 = (index + 1) w_1 = (index + 1)
@ -165,21 +168,20 @@ module ExportHelper
w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间" w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间"
myshixun_complete = myshixun && myshixun.status == 1 myshixun_complete = myshixun && myshixun.status == 1
w_17 = myshixun_complete && w.cost_time ? (game_spend_time w.cost_time) : "未完成" w_17 = myshixun_complete && w.cost_time ? (game_spend_time w.cost_time) : "未完成"
teacher_comments = w.student_works_scores teacher_comment = w.shixun_work_comments.select{|comment| comment.challenge_id == 0}.first
if teacher_comments.present? if teacher_comment.present?
w_18 = "" w_18 = "学生可见:\n #{teacher_comment.comment.to_s} \n\n 老师可见:\n#{teacher_comment.hidden_comment.to_s}"
teacher_comments.each do |t|
user_name = t.user&.real_name
user_time = format_time(t.updated_at)
user_score = t&.score
user_comment = t.comment.present? ? t.comment : "--"
comment_title = "#{user_name} #{user_time.to_s} #{user_score.to_s}\n#{user_comment}\n\n"
w_18 = w_18 + comment_title
end
else else
w_18 = "--" w_18 = "--"
end end
row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18] row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18]
# 关卡评语
shixun.challenges.pluck(:id).each do |challenge_id|
challenge_comment = w.shixun_work_comments.select{|comment| comment.challenge_id == challenge_id}.first
row_cells_column << (challenge_comment.present? ? "学生可见:\n #{challenge_comment.comment.to_s} \n\n 老师可见:\n#{challenge_comment.hidden_comment.to_s}" : "--")
end
row_cells_column = row_cells_column.reject(&:blank?) row_cells_column = row_cells_column.reject(&:blank?)
@work_cells_column.push(row_cells_column) @work_cells_column.push(row_cells_column)
end end

@ -196,7 +196,7 @@ class Course < ApplicationRecord
end end
def all_course_module_types def all_course_module_types
%w[activity announcement online_learning shixun_homework common_homework group_homework exercise attachment course_group graduation poll board] %w[activity announcement online_learning shixun_homework common_homework group_homework exercise attachment course_group graduation poll board statistics]
end end
def get_course_module_by_type(type) def get_course_module_by_type(type)
@ -386,6 +386,7 @@ class Course < ApplicationRecord
when 'attachment' then '资源' when 'attachment' then '资源'
when 'board' then '讨论' when 'board' then '讨论'
when 'course_group' then '分班' when 'course_group' then '分班'
when 'statistics' then '统计'
else '' else ''
end end
end end
@ -404,6 +405,7 @@ class Course < ApplicationRecord
when 'attachment' then 10 when 'attachment' then 10
when 'board' then 11 when 'board' then 11
when 'course_group' then 12 when 'course_group' then 12
when 'statistics' then 13
else 100 else 100
end end
end end

@ -37,6 +37,9 @@ class Exercise < ApplicationRecord
DEADLINE = 3 #已截止 DEADLINE = 3 #已截止
ENDED = 4 #课堂已结束 ENDED = 4 #课堂已结束
def question_scores
exercise_questions.pluck(:question_score).sum
end
def create_exercise_list def create_exercise_list
str = "" str = ""

@ -10,13 +10,15 @@ class Admins::CompetitionStageCreateService < ApplicationService
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
stage = CompetitionStage.create!(competition_id: competition.id, name: params[:stage_name], score_rate: (params[:score_rate].to_i / 100).round(2)) stage = CompetitionStage.create!(competition_id: competition.id, name: params[:stage_name], score_rate: (params[:score_rate].to_i / 100).round(2))
params[:stage].each do |section| unless params[:stage].blank?
stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id, params[:stage].each do |section|
start_time: section["start_time"], end_time: section["end_time"], stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id,
entry: section["entry"], score_source: section["score_source"]) start_time: section["start_time"], end_time: section["end_time"],
section["identifiers"].each do |identifier| entry: section["entry"], score_source: section["score_source"])
CompetitionEntry.create!(competition_stage_section_id: stage_section.id, competition_stage_id: stage.id, section["identifiers"].each do |identifier|
shixun_identifier: identifier) CompetitionEntry.create!(competition_stage_section_id: stage_section.id, competition_stage_id: stage.id,
shixun_identifier: identifier)
end
end end
end end

@ -13,13 +13,15 @@ class Admins::CompetitionStageUpdateService < ApplicationService
stage.competition_stage_sections.destroy_all stage.competition_stage_sections.destroy_all
params[:stage].each do |section| unless params[:stage].blank?
stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id, params[:stage].each do |section|
start_time: section["start_time"], end_time: section["end_time"], stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id,
entry: section["entry"], score_source: section["score_source"]) start_time: section["start_time"], end_time: section["end_time"],
section["identifiers"].each do |identifier| entry: section["entry"], score_source: section["score_source"])
CompetitionEntry.create!(competition_stage_section_id: stage_section.id, competition_stage_id: stage.id, section["identifiers"].each do |identifier|
shixun_identifier: identifier) CompetitionEntry.create!(competition_stage_section_id: stage_section.id, competition_stage_id: stage.id,
shixun_identifier: identifier)
end
end end
end end

@ -360,7 +360,7 @@
</div><span class=" mt-2">%</span> </div><span class=" mt-2">%</span>
<div class="flex-1"> <div class="flex-1">
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20 add-task-sub">新增子阶段</a> <a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20 add-task-sub">新增子阶段</a>
<% if stage.max_end_time > Time.now %> <% if stage.max_end_time && stage.max_end_time > Time.now %>
<%= agree_link '发送短信提醒', send_message_admins_competition_competition_stage_path(@competition, stage, element: ".send-message-#{stage.id}"), <%= agree_link '发送短信提醒', send_message_admins_competition_competition_stage_path(@competition, stage, element: ".send-message-#{stage.id}"),
class: 'btn btn-outline-primary ml20', 'data-confirm': '确认执行发送短信操作?' %> class: 'btn btn-outline-primary ml20', 'data-confirm': '确认执行发送短信操作?' %>
<% end %> <% end %>
@ -492,6 +492,7 @@
</div> </div>
<% end %> <% end %>
<% end %> <% end %>
<div class="error my-2 danger text-danger"></div>
</div> </div>
</div> </div>
</div> </div>

@ -0,0 +1,7 @@
class AddStatisticsToCourseModule < ActiveRecord::Migration[5.2]
def change
Course.includes(:course_modules).all.each do |course|
CourseModule.create!(course_id: course.id, module_type: "statistics", hidden:0, module_name: "统计", position: course.course_modules.pluck(:position).max + 1)
end
end
end
Loading…
Cancel
Save