未答测验的学生在测验截止时间到了后算作零分

This commit is contained in:
cxt 2015-12-18 12:47:34 +08:00
parent 2faddd7d75
commit b65e84d166
3 changed files with 17 additions and 8 deletions

View File

@ -16,10 +16,7 @@ class ExerciseController < ApplicationController
exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
end
end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
end_exercises.each do |exercise|
exercise.update_column('exercise_status', 3)
end
if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?)
render_403
return
@ -46,10 +43,7 @@ class ExerciseController < ApplicationController
exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
end
end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
end_exercises.each do |exercise|
exercise.update_column('exercise_status', 3)
end
unless User.current.member_of_course?(@course) || User.current.admin?
render_403
return

View File

@ -75,6 +75,9 @@
<li class="hworkList130 c_grey student_work_<%= exercise.id%>">
<% if exercise.created_at%>
<%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>&nbsp;
<% if @exercise.end_time <= exercise.created_at %>
<span class="c_red">[未答]</span>
<% end %>
<% end %>
</li>

View File

@ -14,9 +14,21 @@ namespace :exercise_publish do
end
task :end => :environment do
include ExerciseHelper
exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
exercises.each do |exercise|
course = exercise.course
exercise.update_column('exercise_status', 3)
course.student.each do |student|
if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,exercise.id).empty?
ExerciseUser.create(:user_id => student.student_id, :exercise_id => exercise.id, :start_at => exercise.end_time, :status => true,:score=>0)
end
=begin
s_score = calculate_student_score(exercise, student.student)
exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", student.student_id, exercise.id).first
exercise_user.update_attributes(:score => s_score)
=end
end
end
end
end