1、系统评分的时候对成绩进行赋值

2、去掉错误的编程得分计算方法
This commit is contained in:
sw 2015-09-17 16:53:38 +08:00
parent f6f3d83c5e
commit 9c20368274
3 changed files with 2 additions and 42 deletions

View File

@ -8,7 +8,6 @@ class StudentWorkController < ApplicationController
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
protect_from_forgery :except => :set_program_score
###
def program_test
@ -360,46 +359,6 @@ class StudentWorkController < ApplicationController
end
end
#设置编程作业得分
def set_program_score
stundet_work = StudentWork.find_by_id params[:student_work_id]
@course = stundet_work.homework_common.course
student_score_count = 0
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
homework_common = stundet_work.homework_common
params[:results].each do |result|
homework_tests = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'")
homework_tests.each do |homework_test|
student_work_test = StudentWorkTest.new
student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test
student_work_test.result = result[:status]
if student_work_test.result == 0
student_score_count += 1
end
student_work_test.error_msg = params[:compile_error_msg]
student_work_test.save!
end
end
unless homework_common.homework_tests.empty?
stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count
if stundet_work.teacher_score.nil?
if stundet_work.teaching_asistant_score.nil?
stundet_work.final_score = stundet_work.student_score
else
final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")
final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}"))
final_score = final_ta_score + final_s_score
stundet_work.final_score = format("%.1f",final_score.to_f)
end
end
stundet_work.save!
end
end
end
private
#获取作业
def find_homework

View File

@ -31,6 +31,7 @@ class StudentWork < ActiveRecord::Base
else
self.system_score = last_test.test_score
end
self.final_score = self.system_score
end
end

View File

@ -119,7 +119,7 @@ RedmineApp::Application.routes.draw do
get 'student_work_absence_penalty'
get 'absence_penalty_list'
get 'evaluation_list'
post 'set_program_score'
# post 'set_program_score'
post 'program_test'
end
end