28 lines
945 B
Ruby
28 lines
945 B
Ruby
|
class HomeworkAttachController < ApplicationController
|
||
|
#显示作业信息
|
||
|
def show
|
||
|
@homework = HomeworkAttach.find(params[:id])
|
||
|
# 打分统计
|
||
|
stars_reates = @homework.
|
||
|
rates(:quality)
|
||
|
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
|
||
|
stars_status = stars_reates.select("stars, count(*) as scount").
|
||
|
group("stars")
|
||
|
@stars_status_map = Hash.new(0.0)
|
||
|
stars_status.each do |star_status|
|
||
|
percent = (star_status.scount * 1.0/ stars_reates_count) * 100.to_f
|
||
|
percent_m = format("%.2f", percent)
|
||
|
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
|
||
|
percent_m.to_s + "%"
|
||
|
end
|
||
|
@jours = @homework.journals_for_messages.order("created_on DESC")
|
||
|
end
|
||
|
|
||
|
def destroyjours
|
||
|
@homework = HomeworkAttach.find(params[:homework_id])
|
||
|
JournalsForMessage.delete_message(params[:object_id])
|
||
|
redirect_to homework_attach_path(@homework)
|
||
|
end
|
||
|
end
|
||
|
|