试卷实训题的测试集打分

dev_local
cxt 6 years ago
parent 7ee4031419
commit dada8cfeba

@ -1416,9 +1416,9 @@ class ExerciseController < ApplicationController
exercise_cha_score = 0 exercise_cha_score = 0
answer_status = 0 answer_status = 0
challeng_path = challenge_path exercise_cha.challenge.path challeng_path = challenge_path exercise_cha.challenge.path
if game.status == 2 && game.final_score >= 0 if game.final_score >= 0
exercise_cha_score = exercise_cha.question_score exercise_cha_score = game.real_score exercise_cha.question_score
answer_status = 1 answer_status = game.status == 2 ? 1 : 0
end end
if exercise_cha.exercise_shixun_answers.where(:user_id => user.id).empty? if exercise_cha.exercise_shixun_answers.where(:user_id => user.id).empty?
if GameCode.where(:game_id => game.try(:id), :path => challeng_path).first.present? if GameCode.where(:game_id => game.try(:id), :path => challeng_path).first.present?

@ -20,6 +20,11 @@ class Game < ActiveRecord::Base
:answer_open, :test_sets_view, :cost_time, :star, :modify_time]) } :answer_open, :test_sets_view, :cost_time, :star, :modify_time]) }
# 根据得分比例来算实际得分(试卷、实训作业)
def real_score score
self.final_score == challenge.score ? self.final_score : (self.final_score.to_f / challenge.score) * score
end
def had_done def had_done
myshixun = self.myshixun myshixun = self.myshixun
challenge_count = myshixun.games.count challenge_count = myshixun.games.count

@ -31,7 +31,8 @@ namespace :exercise_publish do
score2 = 0 score2 = 0
score3 = 0 score3 = 0
score4 = 0 score4 = 0
exercise_qustions = exercise.exercise_questions exercise_user = exercise.exercise_users.where(user_id: user.id).first
exercise_qustions = exercise.user_question_list(exercise_user.try(:id))
exercise_qustions.each do |question| exercise_qustions.each do |question|
if question.question_type != 5 if question.question_type != 5
answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}")
@ -69,9 +70,9 @@ namespace :exercise_publish do
answer_status = 0 answer_status = 0
cha_path = exercise_cha.challenge.path.present? ? exercise_cha.challenge.path.split("") : [] cha_path = exercise_cha.challenge.path.present? ? exercise_cha.challenge.path.split("") : []
challeng_path = cha_path.reject(&:blank?)[0].try(:strip) challeng_path = cha_path.reject(&:blank?)[0].try(:strip)
if game.status == 2 && game.final_score >= 0 if game.final_score >= 0
exercise_cha_score = exercise_cha.question_score exercise_cha_score = game.real_score exercise_cha.question_score
answer_status = 1 answer_status = game.status == 2 ? 1 : 0
end end
if exercise_cha.exercise_shixun_answers.where(:user_id => user.id).empty? if exercise_cha.exercise_shixun_answers.where(:user_id => user.id).empty?
if GameCode.where(:game_id => game.try(:id), :path => challeng_path).first.present? if GameCode.where(:game_id => game.try(:id), :path => challeng_path).first.present?

Loading…
Cancel
Save