trustie作业评分优化
This commit is contained in:
parent
d40d33740f
commit
d894a925c9
|
@ -906,7 +906,6 @@ class StudentWorkController < ApplicationController
|
|||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
|
||||
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
|
||||
@score = student_work_score @work,User.current
|
||||
#@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
#@score.score = params[:score] if params[:score]
|
||||
#if User.current.admin?
|
||||
|
@ -918,16 +917,19 @@ class StudentWorkController < ApplicationController
|
|||
#@is_new = false
|
||||
@is_last_a = @work.student_works_scores.empty?
|
||||
@new_score = StudentWorksScore.new
|
||||
if @score && params[:score]
|
||||
@new_score.score = params[:score].to_i == -1 ? @score.score : params[:score]
|
||||
elsif @score.nil? && params[:score]
|
||||
@new_score.score = params[:score].to_i == -1 ? nil : params[:score]
|
||||
if params[:score] == -1
|
||||
score = student_work_score @work,User.current
|
||||
@new_score.score = @score.try(:score)
|
||||
else
|
||||
@new_score.score = params[:score]
|
||||
end
|
||||
|
||||
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
@new_score.user_id = User.current.id
|
||||
@new_score.student_work_id = @work.id
|
||||
if @is_teacher && !@new_score.score.nil? && @work.work_status == 0
|
||||
@work.update_attributes(:work_status => 1, :commit_time => Time.now)
|
||||
@work.work_status = 1
|
||||
@work.commit_time = Time.now
|
||||
#更新CourseHomeworkStatistics中学生的已交作品数、未交作品数
|
||||
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
|
||||
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||
|
@ -939,16 +941,6 @@ class StudentWorkController < ApplicationController
|
|||
role = User.current.members.where("course_id = ?",@course.id).first.roles.where("is_current = 1").first.name
|
||||
@new_score.reviewer_role = get_role_by_name(role)
|
||||
end
|
||||
if @score
|
||||
if @is_teacher
|
||||
@is_new = true
|
||||
@is_last_a = false
|
||||
else
|
||||
@is_new = false
|
||||
end
|
||||
else
|
||||
@is_new = true
|
||||
end
|
||||
|
||||
@new_score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@new_score)
|
||||
|
@ -994,7 +986,7 @@ class StudentWorkController < ApplicationController
|
|||
@homework.update_column('updated_at', Time.now)
|
||||
update_course_activity(@homework.class,@homework.id)
|
||||
update_user_activity(@homework.class,@homework.id)
|
||||
update_org_activity(@homework.class,@homework.id)
|
||||
# update_org_activity(@homework.class,@homework.id)
|
||||
if @work.save
|
||||
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
|
||||
@count = @homework.student_works.has_committed.count
|
||||
|
|
|
@ -206,11 +206,9 @@ class StudentWork < ActiveRecord::Base
|
|||
course_homework_statistics = CourseHomeworkStatistics.where(:user_id => self.user_id, :course_id => self.homework_common.course_id).first
|
||||
if course_homework_statistics
|
||||
course = self.homework_common.course
|
||||
homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
||||
student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
|
||||
user = self.user
|
||||
average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||
total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||
average_score = user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||
total_score = user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:homework_common_id => course.homework_commons.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||
course_homework_statistics.update_attributes(:average_score => average_score, :total_score => total_score)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% is_member_work = @homework.homework_type == 3 && @work.student_work_projects.empty? %>
|
||||
<% is_member_work = @homework.homework_type == 3 && !@is_group_leader %>
|
||||
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @new_score,:is_member_work => is_member_work}) %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class AddIndexToMessageAll < ActiveRecord::Migration
|
||||
def change
|
||||
remove_index :message_alls, name: 'index_message_alls_on_user_id_and_message_id_and_created_at'
|
||||
remove_index :message_alls, :message_type
|
||||
add_index :message_alls, [:message_id]
|
||||
end
|
||||
end
|
1546
db/schema.rb
1546
db/schema.rb
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue