Merge branch 'szzh' of http://xianbo_trustie2@repository.trustie.net/xianbo/trustie2.git into email_verify
This commit is contained in:
commit
7442cc1ca4
|
@ -6,6 +6,7 @@ module Mobile
|
|||
require_relative 'apis/watches'
|
||||
require_relative 'apis/upgrade'
|
||||
require_relative 'apis/homeworks'
|
||||
require_relative 'apis/comments'
|
||||
class API < Grape::API
|
||||
version 'v1', using: :path
|
||||
format :json
|
||||
|
@ -37,6 +38,7 @@ module Mobile
|
|||
mount Apis::Watches
|
||||
mount Apis::Upgrade
|
||||
mount Apis::Homeworks
|
||||
mount Apis::Comments
|
||||
|
||||
#add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
|
||||
#add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#coding=utf-8
|
||||
module Mobile
|
||||
module Apis
|
||||
class Comments < Grape::API
|
||||
resource :comments do
|
||||
desc '课程通知评论'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :comments, type: String
|
||||
end
|
||||
post ':id' do
|
||||
cs = CommentService.new
|
||||
cs_params = {
|
||||
id: params[:id],
|
||||
comment: params.reject{|k,v| [:id].include?(k)}}
|
||||
comments = cs.news_comments cs_params,current_user
|
||||
raise "create comments failed #{comments.errors.full_messages}" if comments.new_record?
|
||||
present :data, comments, with: Mobile::Entities::Comment
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc '作业留言(教师布置的作业)'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :message,type: String, desc: '留言'
|
||||
#optional :reference_content, type: String ,desc: '引用的内容'
|
||||
#optional :reference_user_id, type: Integer,desc: '被引用的人'
|
||||
end
|
||||
post ':id/create_homework_message' do
|
||||
cs_params = {
|
||||
id: params[:id],
|
||||
token: params[:token],
|
||||
reference_content: params[:reference_content],
|
||||
bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}}
|
||||
cs = CommentService.new
|
||||
message = cs.homework_message cs_params,current_user
|
||||
present :data, message, with: Mobile::Entities::Jours
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc '课程留言'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :course_message,type: String, desc: '留言'
|
||||
end
|
||||
post ':id/leave_course_message' do
|
||||
cs_params = {
|
||||
id: params[:id],
|
||||
token: params[:token],
|
||||
new_form: params.reject{|k,v| [:id,:token].include?(k)}}
|
||||
cs = CommentService.new
|
||||
message = cs.leave_course_message cs_params,current_user
|
||||
present :data, message, with: Mobile::Entities::Jours
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc '回复留言'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :reference_id, type: Integer,desc: '所属留言树的根留言id(最顶层的非回复的留言,留言对象中的m_parent_id)'
|
||||
requires :reference_user_id,type: Integer ,desc: '被回复的留言的作者id'
|
||||
#requires :reference_message_id,type: Integer,desc: '被回复的留言的id'
|
||||
requires :user_notes,type: String,desc: '留言的内容'
|
||||
requires :jour_type,type: String,desc: '等于父留言的jour_type'
|
||||
requires :jour_id,type:Integer, desc: '等于父留言的jour_id'
|
||||
end
|
||||
post ':reference_message_id/create_reply'do
|
||||
cs = CommentService.new
|
||||
message = cs.create_reply params,current_user
|
||||
raise "create reply failed #{message.errors.full_messages}" if message.new_record?
|
||||
present :data, message, with: Mobile::Entities::Jours
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -188,17 +188,18 @@ module Mobile
|
|||
|
||||
desc "课程通知列表"
|
||||
params do
|
||||
optional :token, type: String
|
||||
end
|
||||
get ":course_id/news" do
|
||||
cs = CoursesService.new
|
||||
news = cs.course_news_list params
|
||||
news = cs.course_news_list params,current_user.nil? ? User.find(2):current_user
|
||||
present :data, news, with: Mobile::Entities::News
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "显示课程通知"
|
||||
params do
|
||||
|
||||
optional :token, type: String
|
||||
end
|
||||
get "news/:id" do
|
||||
cs = CoursesService.new
|
||||
|
@ -208,6 +209,16 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc '课程动态'
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
get "course_dynamic/:id" do
|
||||
cs = CoursesService.new
|
||||
count = cs.course_dynamic(params,current_user)
|
||||
present :data, count, with: Mobile::Entities::CourseDynamic
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -22,13 +22,15 @@ module Mobile
|
|||
|
||||
desc "显示用户"
|
||||
params do
|
||||
|
||||
requires :id, type: Integer
|
||||
end
|
||||
get ':id' do
|
||||
us = UsersService.new
|
||||
ue = us.show_user params
|
||||
present :data, ue,with: Mobile::Entities::User
|
||||
present :status, 0
|
||||
route_param :id do
|
||||
get do
|
||||
us = UsersService.new
|
||||
ue = us.show_user params
|
||||
present :data, ue,with: Mobile::Entities::User
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
|
||||
desc "修改用户"
|
||||
|
@ -81,7 +83,7 @@ module Mobile
|
|||
params do
|
||||
requires :name, type: String, desc: '用户名关键字'
|
||||
end
|
||||
get 'search' do
|
||||
get 'search/search_user' do
|
||||
us = UsersService.new
|
||||
user = us.search_user params
|
||||
present :data, user, with: Mobile::Entities::User
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class Comment < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.comment_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::Comment)
|
||||
if f.respond_to?(field)
|
||||
if field == :created_on
|
||||
format_time(f.send(field))
|
||||
else
|
||||
f.send(field)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
comment_expose :id
|
||||
expose :author, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a? ::Comment
|
||||
c.author
|
||||
end
|
||||
end
|
||||
comment_expose :comments
|
||||
comment_expose :created_on
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class CourseDynamic < Grape::Entity
|
||||
def self.course_dynamic_expose(field)
|
||||
expose field do |c,opt|
|
||||
c[field] if (c.is_a?(Hash) && c.key?(field))
|
||||
end
|
||||
end
|
||||
|
||||
course_dynamic_expose :course_name
|
||||
course_dynamic_expose :need_anonymous_comments_count
|
||||
course_dynamic_expose :student_commit_number
|
||||
course_dynamic_expose :news_count
|
||||
course_dynamic_expose :message_count
|
||||
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)
|
||||
|
|
|
@ -18,12 +18,15 @@ module Mobile
|
|||
end
|
||||
end
|
||||
jours_expose :id
|
||||
jours_expose :jour_type
|
||||
jours_expose :jour_id
|
||||
expose :user,using: Mobile::Entities::User do |f, opt|
|
||||
f.user
|
||||
end
|
||||
jours_expose :created_on
|
||||
jours_expose :notes
|
||||
jours_expose :m_reply_id
|
||||
jours_expose :m_parent_id
|
||||
expose :reply_user,using: Mobile::Entities::User do |f, opt|
|
||||
f.at_user
|
||||
end
|
||||
|
|
|
@ -34,7 +34,11 @@ module Mobile
|
|||
#评论数量
|
||||
news_expose :comments_count
|
||||
#评论
|
||||
news_expose :comments
|
||||
expose :comments, using: Mobile::Entities::Comment do |f, opt|
|
||||
if f.is_a?(Hash) && f.key?(:comments)
|
||||
f[:comments]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -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 = []
|
||||
# 取十个
|
||||
|
|
|
@ -37,4 +37,27 @@ module ApiHelper
|
|||
end
|
||||
result
|
||||
end
|
||||
|
||||
#########################################################
|
||||
#sw
|
||||
#获取课程未匿评数量
|
||||
#param: user => "用户", course_id => "查询的课程ID"
|
||||
#return: 作业的数量
|
||||
#########################################################
|
||||
def get_course_anonymous_evaluation user,course
|
||||
count = 0
|
||||
if course
|
||||
is_teacher = is_course_teacher user,course
|
||||
if is_teacher #如果是老师,显示学生提交的作业数
|
||||
course.homeworks.each do |bid|
|
||||
count += bid.homeworks.count
|
||||
end
|
||||
else #如果是学生,显示未匿评的数量
|
||||
course.homeworks.each do |bid|
|
||||
count += get_student_not_batch_homework_list bid,user
|
||||
end
|
||||
end
|
||||
end
|
||||
[count,is_teacher]
|
||||
end
|
||||
end
|
|
@ -130,4 +130,22 @@ module HomeworkAttachHelper
|
|||
WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id} ORDER BY m_score DESC")
|
||||
student_batch_homework_list
|
||||
end
|
||||
|
||||
#########################################################
|
||||
#sw
|
||||
#获取学生未进行匿评的数量
|
||||
#param: bid => 作业 user => 用户
|
||||
#return 指定用户未进行匿评的作业的数量
|
||||
#user必须是学生用户
|
||||
#######################################################
|
||||
def get_student_not_batch_homework_list bid,user
|
||||
HomeworkAttach.find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1) AS t_score,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
|
||||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{user.id} AND is_teacher_score = 0) AS m_score
|
||||
FROM homework_attaches
|
||||
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||
WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id}) AS table1
|
||||
WHERE table1.m_score IS NULL").count
|
||||
end
|
||||
end
|
|
@ -93,7 +93,9 @@ class Bid < ActiveRecord::Base
|
|||
# 'deadline'
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
||||
jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
||||
self.journals_for_messages << jfm
|
||||
jfm
|
||||
else
|
||||
jfm = self.journals_for_messages.build(options)
|
||||
jfm.save
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
class CommentService
|
||||
#评论
|
||||
def news_comments params,current_user
|
||||
@news = News.find(params[:id])
|
||||
@course = @news.course
|
||||
if @course.nil?
|
||||
raise 'news in unknown course'
|
||||
end
|
||||
raise Unauthorized unless @news.commentable?(current_user)
|
||||
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
|
||||
raise '403'
|
||||
end
|
||||
@comment = Comment.new
|
||||
@comment.send(:safe_attributes=,params[:comment],current_user)
|
||||
@comment.author = current_user
|
||||
@news.comments << @comment
|
||||
@comment
|
||||
end
|
||||
|
||||
#作业留言
|
||||
def homework_message params,current_user
|
||||
@bid = Bid.find(params[:id], :include => [{:homeworks => :user}])
|
||||
if params[:bid_message][:message].size>0
|
||||
if params[:reference_content]
|
||||
message = params[:bid_message][:message] + "\n" + params[:reference_content]
|
||||
else
|
||||
message = params[:bid_message][:message]
|
||||
@m = message
|
||||
end
|
||||
refer_user_id = params[:bid_message][:reference_user_id].to_i
|
||||
jfm = @bid.add_jour(current_user, message, refer_user_id)
|
||||
end
|
||||
#@user = @bid.author
|
||||
#@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
#@jour = paginateHelper @jours,10
|
||||
@bid.set_commit(@feedback_count)
|
||||
jfm
|
||||
end
|
||||
#课程留言接口
|
||||
def leave_course_message params,current_user
|
||||
message = params[:new_form][:course_message]
|
||||
feedback = Course.add_new_jour(current_user, message, params[:id])
|
||||
feedback
|
||||
end
|
||||
|
||||
#回复留言接口
|
||||
def create_reply params,current_user
|
||||
# 这里是创建回复所使用的方法,此方法只针对回复,每一个新的留言并不在此方法管理范围内。
|
||||
# 由于多个地方用到了留言,而之前的表设计也有jour_type/jour_id这类信息
|
||||
# 所以在方法 add_reply_adapter 中判断所有调用此方法的来源页面,
|
||||
# 为了保证兼容以往所有的代码,保证以往的方法可以调用,在返回页面中都做了各式各样的判断。
|
||||
# 页面保证 render new_respond/journal_reply
|
||||
# 修改 add_reply_adapter 中可以确保留言创建成功
|
||||
# 删除留言功能要调用destroy,也记得在destroy.js中修改
|
||||
|
||||
# deny api. api useless
|
||||
parent_id = params[:reference_id]
|
||||
author_id = current_user.id
|
||||
reply_user_id = params[:reference_user_id]
|
||||
reply_id = params[:reference_message_id] # 暂时不实现
|
||||
content = params[:user_notes]
|
||||
jour_type = params[:jour_type]
|
||||
jour_id = params[:jour_id]
|
||||
@show_name = params[:show_name] == "true"
|
||||
options = {
|
||||
:jour_id => jour_id,
|
||||
:jour_type => jour_type,
|
||||
:user_id => author_id,
|
||||
:status => true,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
:notes => content,
|
||||
:is_readed => false}
|
||||
@jfm = ::JournalsForMessage.new(options)
|
||||
#@save_succ = true if @jfm.errors.empty?
|
||||
@jfm.save
|
||||
@jfm
|
||||
end
|
||||
|
||||
end
|
|
@ -2,6 +2,7 @@ class CoursesService
|
|||
include ApplicationHelper
|
||||
include CoursesHelper
|
||||
include HomeworkAttachHelper
|
||||
include ApiHelper
|
||||
#TODO:尚未整合权限系统
|
||||
#参数school_id为0或不传时返回所有课程,否则返回对应学校的课程
|
||||
#参数per_page_count分页功能,每页显示的课程数
|
||||
|
@ -106,11 +107,14 @@ class CoursesService
|
|||
end
|
||||
|
||||
#课程通知列表
|
||||
def course_news_list params
|
||||
def course_news_list params,current_user
|
||||
if params[:course_id] && @course==nil
|
||||
@course = Course.find(params[:course_id])
|
||||
end
|
||||
scope = @course ? @course.news.course_visible : News.course_visible
|
||||
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
|
||||
raise '403'
|
||||
end
|
||||
scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user)
|
||||
news = []
|
||||
scope.each do |n|
|
||||
news << {:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
|
||||
|
@ -128,9 +132,16 @@ class CoursesService
|
|||
#显示课程通知(包括评论) 需验证权限
|
||||
def show_course_news params,current_user
|
||||
@news = News.find(params[:id])
|
||||
@course = @news.course
|
||||
if @course
|
||||
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
|
||||
raise '403'
|
||||
end
|
||||
end
|
||||
@comments = @news.comments
|
||||
@comments.reverse! if current_user.wants_comments_in_reverse_order?
|
||||
{:news => @news,:comments => @comments}
|
||||
|
||||
#comments = []
|
||||
#@comments.each do |comment|
|
||||
# comments << {:author_id => comment.author_id,:author_name => comment.author.name,:commont_content => comment.comments,:time => format_time(comment.created_on)}
|
||||
|
@ -316,6 +327,22 @@ class CoursesService
|
|||
end
|
||||
end
|
||||
|
||||
def course_dynamic(params,current_user)
|
||||
course = Course.find(params[:id])
|
||||
if current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course)))
|
||||
raise '403'
|
||||
end
|
||||
count,is_teacher = get_course_anonymous_evaluation current_user,course
|
||||
if is_teacher
|
||||
student_commit_number = count
|
||||
else
|
||||
need_anonymous_comments_count = count
|
||||
end
|
||||
news_count = course.news.count
|
||||
message_count = course.journals_for_messages.count
|
||||
{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count}
|
||||
end
|
||||
|
||||
private
|
||||
def show_homework_info course,bid,current_user,is_course_teacher
|
||||
author = bid.author.lastname + bid.author.firstname
|
||||
|
@ -351,4 +378,6 @@ class CoursesService
|
|||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<div class="attachments" style="font-weight:normal;">
|
||||
<% is_float ||= false %>
|
||||
<% for attachment in attachments %>
|
||||
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<div style="width:65%;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;float: left;">
|
||||
<%if is_float%>
|
||||
<div style="max-width:55%;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;float: left;">
|
||||
<% end%>
|
||||
<span title="<%= attachment.filename%>" id = "attachment_">
|
||||
<% if options[:length] %>
|
||||
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%>
|
||||
|
@ -9,7 +12,10 @@
|
|||
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<%if is_float%>
|
||||
</div>
|
||||
<% end%>
|
||||
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments',
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<p>
|
||||
<% if @memo.attachments.any?%>
|
||||
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %>
|
||||
<% end %>
|
||||
</p>
|
||||
<div class="clearfix"></div>
|
||||
|
@ -136,7 +136,7 @@
|
|||
<p>
|
||||
<% if reply.attachments.any?%>
|
||||
<% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options, :is_float => true} %>
|
||||
<% end %>
|
||||
</p>
|
||||
</td>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<script type="text/javascript">
|
||||
function close_alert_form(){hideModal("#alert_form");}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="alert_form">
|
||||
<div class="upload_con">
|
||||
<div class="polls_alert_upload_box">
|
||||
<p class="polls_alert_box_p">
|
||||
<%= message%>
|
||||
</p>
|
||||
<div class="polls_alert_btn_box">
|
||||
<a class="upload_btn" onclick="close_alert_form();">
|
||||
确 定
|
||||
</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,2 +1,10 @@
|
|||
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
|
||||
alert("发布成功");
|
||||
$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>");
|
||||
showModal('ajax-modal', '180px');
|
||||
$('#ajax-modal').css('height','111px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='#' onclick='close_alert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("poll_alert_form");
|
|
@ -1,2 +1,10 @@
|
|||
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
|
||||
alert("取消成功");
|
||||
$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>");
|
||||
showModal('ajax-modal', '180px');
|
||||
$('#ajax-modal').css('height','80px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='#' onclick='close_alert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("poll_alert_form");
|
|
@ -2504,6 +2504,7 @@ zh:
|
|||
label_poll_result: 问卷调查_问卷统计
|
||||
label_answer: 答案:
|
||||
label_poll_answer_valid_result: 以上为有效问答题答案!
|
||||
label_poll_republish_success: 取消成功
|
||||
label_answer_total: 总计:
|
||||
label_join_project: 加入项目
|
||||
label_technical_support: 技术支持:
|
||||
|
@ -2538,9 +2539,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: 组织
|
||||
|
|
|
@ -145,3 +145,9 @@ a:hover.btn_pu{ background:#3cb761;}
|
|||
.polls_title_w { width:330px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
|
||||
.polls_de_grey{ color:#b1b1b1;padding-left: 5px;}
|
||||
.ml5{ margin-left:5px;}
|
||||
|
||||
/******确定弹框***********/
|
||||
.poll_alert_form{width:140px;height:180px;position:fixed;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
|
||||
.polls_alert_btn_box{width: 100%;margin: 0 auto;padding-left: 45px;}
|
||||
.polls_alert_upload_box{ width:120px; margin:15px auto;}
|
||||
.polls_alert_box_p{ font-size:14px; padding-left: 45px;padding-top: 10px;}
|
||||
|
|
Loading…
Reference in New Issue