parent
93c7deebc4
commit
226d5e9889
|
@ -1048,27 +1048,8 @@ class BidsController < ApplicationController
|
|||
end
|
||||
|
||||
def alert_anonymous_comment
|
||||
@bid = Bid.find params[:id]
|
||||
@course = @bid.courses.first
|
||||
if @bid.comment_status == 0
|
||||
@totle_size = searchStudent(@course).size
|
||||
@cur_size = @bid.homeworks.size
|
||||
elsif @bid.comment_status == 1
|
||||
@totle_size = 0
|
||||
@bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count}
|
||||
teachers = "("
|
||||
teacher_members = searchTeacherAndAssistant(@course)
|
||||
teacher_members.each do |member|
|
||||
if member == teacher_members.last
|
||||
teachers += member.user_id.to_s + ")"
|
||||
else
|
||||
teachers += member.user_id.to_s + ","
|
||||
end
|
||||
end
|
||||
@cur_size = 0
|
||||
@bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
|
||||
end
|
||||
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
|
||||
hws = HomeworkService.new
|
||||
@bid,@totle_size,@cur_size,@percent = hws.alert_homework_anonymous_comment(params)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
#coding=utf-8
|
||||
class HomeworkService
|
||||
include CoursesHelper
|
||||
include AttachmentsHelper
|
||||
|
||||
#作业详情(老师才显示启动匿评,学生不显示 )
|
||||
#bid.comment_status=0 启动匿评
|
||||
#bid.comment_status=1 关闭匿评
|
||||
#many_times 第几次(作业)
|
||||
#is_teacher 判断是否为该课程老师
|
||||
#@state=0 启动匿评
|
||||
#@state=1 关闭匿评
|
||||
#@state=2 匿评结束
|
||||
def show_homework params
|
||||
@bid = Bid.find(params[:id])
|
||||
course = @bid.courses.first
|
||||
is_teacher = is_course_teacher(User.current, course)
|
||||
author = @bid.author.firstname + @bid.author.lastname
|
||||
many_times = course.homeworks.index(@bid) + 1
|
||||
name = @bid.name
|
||||
homework_count = @bid.homeworks.count
|
||||
description = @bid.description
|
||||
if is_teacher && bid.open_anonymous_evaluation == 1 && bid.homeworks.count >= 2
|
||||
case bid.comment_status
|
||||
when 0
|
||||
alert_anonymous_comment_bid_path(bid)
|
||||
when 1
|
||||
alert_anonymous_comment_bid_path(bid)
|
||||
when 2
|
||||
raise '匿评结束'
|
||||
end
|
||||
if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
|
||||
@state = bid.comment_status
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -49,6 +44,7 @@ class HomeworkService
|
|||
@bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
|
||||
end
|
||||
@percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
|
||||
[@bid,@totle_size,@cur_size,@percent]
|
||||
end
|
||||
|
||||
#匿评作品详情
|
||||
|
@ -66,8 +62,8 @@ class HomeworkService
|
|||
end
|
||||
end
|
||||
|
||||
#作品打分
|
||||
def add_score_and_jour
|
||||
#作品打分/留言
|
||||
def add_score_and_jour params
|
||||
@is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value]
|
||||
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
|
||||
@homework = HomeworkAttach.find(params[:homework_id])
|
||||
|
@ -80,5 +76,21 @@ class HomeworkService
|
|||
end
|
||||
end
|
||||
|
||||
#作品留言
|
||||
def get_works_jours params
|
||||
@bid = Bid.find params[:id]
|
||||
@user = @bid.author
|
||||
@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jour = paginateHelper @jours,10
|
||||
end
|
||||
|
||||
#匿评作品老师评论
|
||||
#匿评作品学生评论列表TODO:未完成,需继续
|
||||
def anonmous_works_list
|
||||
@is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value]
|
||||
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
|
||||
@homework = HomeworkAttach.find(params[:homework_id])
|
||||
@stars_reates = @homework.rates(:quality)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue