Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
da56477ed0
|
@ -70,6 +70,32 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc "作品打分"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :is_teacher, type: String,desc: '是否为教师(匿评作品详情返回的结果中可获取此参数的值)'
|
||||
requires :is_anonymous_comments, type: String, desc: '是否为匿评(匿评作品详情返回的结果中可获取此参数的值)'
|
||||
optional :stars_value, type: Integer,desc: '用户给出的评分'
|
||||
optional :cur_page,type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值'
|
||||
optional :cur_type, type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值'
|
||||
optional :user_message, type: String, desc: '用户评论'
|
||||
end
|
||||
|
||||
post ':homework_id/scoring' do
|
||||
cs_params = {
|
||||
new_form: params.reject{|k,v| [:token,:is_teacher,:is_anonymous_comments,:stars_value,:cur_page,:cur_type,:homework_id].include?(k)},
|
||||
token: params[:token],
|
||||
is_teacher: params[:is_teacher],
|
||||
is_anonymous_comments: params[:is_anonymous_comments],
|
||||
stars_value: params[:stars_value],
|
||||
cur_page: params[:cur_page],
|
||||
cur_type: params[:cur_type],
|
||||
homework_id: params[:homework_id]
|
||||
}
|
||||
Homeworks.get_service.add_score_and_jour cs_params,current_user
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,8 @@ module Mobile
|
|||
case field
|
||||
when :homework_times
|
||||
f.bid.courses.first.homeworks.index(f.bid) + 1 unless (f.bid.nil? || f.bid.courses.nil? || f.bid.courses.first.nil?)
|
||||
when :comment_status
|
||||
f.bid.comment_status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -28,6 +30,8 @@ module Mobile
|
|||
homework_attach_expose :homework_times
|
||||
homework_attach_expose :description
|
||||
homework_attach_expose :created_at
|
||||
#comment_status 0:所属作业尚未开启匿评,1:匿评中 2:匿评结束
|
||||
homework_attach_expose :comment_status
|
||||
expose :attachments,using: Mobile::Entities::Attachment do |f, opt|
|
||||
if f.respond_to?(:attachments)
|
||||
f.send(:attachments)
|
||||
|
|
|
@ -29,7 +29,7 @@ class WelcomeController < ApplicationController
|
|||
unless params[:organization].nil?
|
||||
@cur_projects = Project.find(params[:organization])
|
||||
@organization = @cur_projects.enterprise_name
|
||||
@organization_projects = current_user.admin? ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization)
|
||||
@organization_projects = (current_user.admin? || User.current.member_of?(@cur_projects)) ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization)
|
||||
@e_count = @organization_projects.count
|
||||
@part_projects = []
|
||||
# 取十个
|
||||
|
|
|
@ -141,16 +141,51 @@ class HomeworkService
|
|||
end
|
||||
|
||||
#作品打分/留言
|
||||
def add_score_and_jour params
|
||||
def add_score_and_jour params,current_user
|
||||
@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])
|
||||
comment_status = @homework.bid.comment_status
|
||||
if @is_anonymous_comments && comment_status == 0
|
||||
raise '尚未开启匿评!'
|
||||
end
|
||||
if @is_anonymous_comments && ((@m_score.nil? || @m_score.blank?) || !(params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""))
|
||||
raise '您尚未打分或评论!'
|
||||
end
|
||||
#保存评分
|
||||
@homework.rate(@m_score.to_i,User.current.id,:quality) if @m_score
|
||||
homework = @homework
|
||||
is_teacher = @is_teacher ? 1 : 0
|
||||
#保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0))
|
||||
if @m_score
|
||||
rate = @homework.rates(:quality).where(:rater_id => current_user.id, :is_teacher_score => is_teacher).first
|
||||
if rate
|
||||
rate.stars = @m_score
|
||||
rate.save!
|
||||
else
|
||||
@homework.rates(:quality).new(:stars => @m_score, :rater_id => current_user.id, :is_teacher_score => is_teacher).save!
|
||||
end
|
||||
|
||||
if homework.is_teacher_score == 0
|
||||
if is_teacher == 1
|
||||
homework.score = @m_score
|
||||
homework.is_teacher_score = 1
|
||||
else
|
||||
sql = "SELECT AVG(stars) as stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id}"
|
||||
score= HomeworkAttach.find_by_sql(sql).first.stars
|
||||
homework.score = score
|
||||
end
|
||||
else
|
||||
if is_teacher == 1
|
||||
homework.score = @m_score
|
||||
homework.is_teacher_score = 1
|
||||
end
|
||||
end
|
||||
homework.save!
|
||||
end
|
||||
#保存评论
|
||||
@is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言
|
||||
if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言
|
||||
@homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
|
||||
@homework.addjours current_user.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2520,9 +2520,9 @@ zh:
|
|||
|
||||
# 项目企业模块
|
||||
|
||||
label_all_enterprises: 所有企业
|
||||
label_all_enterprises: 所有组织
|
||||
label_my_enterprise: 我的企业
|
||||
label_enterprise_tips: 暂时还没有该企业对应的项目,系统的其它项目您可能会感兴趣!
|
||||
label_part_enterprise_tips: 您可能对系统的其它项目会感兴趣!
|
||||
label_enterprise_nil: 该模块为最新上线模块,目前还未有项目关联到企业!
|
||||
label_enterprise_tips: 该组织暂时还没创建公开项目,您可能会对系统的其它项目感兴趣!
|
||||
label_part_enterprise_tips: 您可能对系统的其它项目感兴趣!
|
||||
label_enterprise_nil: 该模块为最新上线模块,目前还没有创建企业项目!
|
||||
label_enterprises: 组织
|
||||
|
|
Loading…
Reference in New Issue