forked from jacknudt/trustieforge
Merge remote-tracking branch 'origin/szzh' into guange_dev
This commit is contained in:
commit
d36da76685
1
Gemfile
1
Gemfile
|
|
@ -27,6 +27,7 @@ gem 'spreadsheet'
|
|||
gem 'ruby-ole'
|
||||
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
|
||||
#gem "rmagick", ">= 2.0.0"
|
||||
gem 'binding_of_caller'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ module Mobile
|
|||
present :data, {token: key.access_token, user: api_user}, using: Entities::Auth
|
||||
present :status, 0
|
||||
else
|
||||
raise "无效的用户名或密码"
|
||||
present :message, "无效的用户名或密码"
|
||||
present :status,1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,20 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc '通知评论列表'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :notice_id,type:Integer,desc:'通知id'
|
||||
optional :page,type:Integer,desc:'页码'
|
||||
end
|
||||
get ':notice_id/notice_comments' do
|
||||
cs = CommentService.new
|
||||
comments = cs.notice_comments params,current_user
|
||||
present :data, comments, with: Mobile::Entities::Comment
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ module Mobile
|
|||
module Apis
|
||||
class Courses < Grape::API
|
||||
resource :courses do
|
||||
def self.get_service
|
||||
CoursesService.new
|
||||
end
|
||||
desc "获取所有课程"
|
||||
params do
|
||||
optional :school_id, type: Integer, desc: '传入学校id,返回该学校课程列表'
|
||||
|
|
@ -312,16 +315,19 @@ module Mobile
|
|||
present :status,0
|
||||
end
|
||||
|
||||
desc '课程历次作业总成绩列表'
|
||||
desc '总成绩 or 活跃度列表'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :course_id,type:Integer,desc:'课程id'
|
||||
optional :page,type:Integer,desc:'页码'
|
||||
optional :type,type:Integer,desc:'0是活跃度,1是成绩'
|
||||
end
|
||||
get ':course_id/students_score_list' do
|
||||
cs = CoursesService.new
|
||||
news = cs.students_score_list params,current_user
|
||||
present :data,news,with:Mobile::Entities::User
|
||||
present :data,news[:user_list],with:Mobile::Entities::User
|
||||
present :maxSize,news[:max_size]
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '课程某次作业提交列表 并显示成绩'
|
||||
|
|
@ -334,21 +340,57 @@ module Mobile
|
|||
get ':course_id/student_works_list' do
|
||||
cs = CoursesService.new
|
||||
student_works = cs.student_work_list params,current_user
|
||||
present :data,student_works.all,with:Mobile::Entities::StudentWork
|
||||
present :data,student_works,with:Mobile::Entities::StudentWork
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '开启匿评'
|
||||
desc '讨论区信息'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :course_id,type:Integer,desc:'课程id'
|
||||
requires :homework_id,type:Integer,desc:'作业id'
|
||||
optional :page,type:Integer,desc:'页码'
|
||||
end
|
||||
get ':course_id/start_anonymous_comment' do
|
||||
get ':course_id/board_message_list' do
|
||||
cs = CoursesService.new
|
||||
status = cs.start_anonymous_comment params,current_user
|
||||
present :data,status
|
||||
board_messages_list = cs.board_message_list params,current_user
|
||||
present :data,board_messages_list.all,with:Mobile::Entities::Message
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '讨论区某主题的回复列表'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :board_id,type:Integer,desc:'讨论区id'
|
||||
requires :msg_id,type:Integer,desc:'讨论主题id'
|
||||
optional :page,type:Integer,desc:'页码'
|
||||
end
|
||||
get ':board_id/board_message_reply_list' do
|
||||
cs = Courses.get_service
|
||||
board_messages_list = cs.board_message_reply_list params,current_user
|
||||
present :data,board_messages_list.all,with:Mobile::Entities::Message
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '讨论区回复'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :board_id,type:Integer,desc:'讨论区id'
|
||||
requires :parent_id,type:Integer,desc:'本回复父id'
|
||||
requires :subject,type:String,desc:'本回复主题'
|
||||
requires :content,type:String,desc:'本回复内容'
|
||||
requires :root_id,type:Integer,desc:'本回复根id'
|
||||
requires :quote,type:String,desc:'本回复引用内容'
|
||||
end
|
||||
post ':board_id/board_message_reply' do
|
||||
cs = Courses.get_service
|
||||
board_messages = cs.board_message_reply params,current_user
|
||||
present :data,board_messages,with:Mobile::Entities::Message
|
||||
present :status,0
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,33 +31,33 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc "启动匿评"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
post ':id/start_anonymous_comment' do
|
||||
statue = Homeworks.get_service.start_anonymous_comment params,current_user.nil? ? User.find(2):current_user
|
||||
messages = ""
|
||||
case statue
|
||||
when 1
|
||||
messages = "启动成功"
|
||||
when 2
|
||||
messages = "启动失败,作业总数大于等于2份时才能启动匿评"
|
||||
when 3
|
||||
messages = "已开启匿评,请务重复开启"
|
||||
end
|
||||
present :data,messages
|
||||
present :status, statue
|
||||
end
|
||||
|
||||
desc "关闭匿评"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
post ':id/stop_anonymous_comment' do
|
||||
Homeworks.get_service.stop_anonymous_comment params,current_user.nil? ? User.find(2):current_user
|
||||
present :status, 0
|
||||
end
|
||||
# desc "启动匿评"
|
||||
# params do
|
||||
# requires :token, type: String
|
||||
# end
|
||||
# post ':id/start_anonymous_comment' do
|
||||
# statue = Homeworks.get_service.start_anonymous_comment params,current_user.nil? ? User.find(2):current_user
|
||||
# messages = ""
|
||||
# case statue
|
||||
# when 1
|
||||
# messages = "启动成功"
|
||||
# when 2
|
||||
# messages = "启动失败,作业总数大于等于2份时才能启动匿评"
|
||||
# when 3
|
||||
# messages = "已开启匿评,请务重复开启"
|
||||
# end
|
||||
# present :data,messages
|
||||
# present :status, statue
|
||||
# end
|
||||
#
|
||||
# desc "关闭匿评"
|
||||
# params do
|
||||
# requires :token, type: String
|
||||
# end
|
||||
# post ':id/stop_anonymous_comment' do
|
||||
# Homeworks.get_service.stop_anonymous_comment params,current_user.nil? ? User.find(2):current_user
|
||||
# present :status, 0
|
||||
# end
|
||||
|
||||
desc "匿评作品详情"
|
||||
params do
|
||||
|
|
@ -111,6 +111,45 @@ module Mobile
|
|||
present :status, 0
|
||||
end
|
||||
|
||||
desc '开启匿评'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :course_id,type:Integer,desc:'课程id'
|
||||
requires :homework_id,type:Integer,desc:'作业id'
|
||||
end
|
||||
post ':homework_id/start_anonymous_comment' do
|
||||
hs = Homeworks.get_service
|
||||
status = hs.start_anonymous_comment params,current_user
|
||||
messages = ""
|
||||
case status[:status]
|
||||
when 1
|
||||
messages = "启动成功"
|
||||
when 2
|
||||
messages = "启动失败,作业总数大于等于2份时才能启动匿评"
|
||||
when 3
|
||||
messages = "已开启匿评,请务重复开启"
|
||||
when 4
|
||||
messages = "没有开启匿评的权限"
|
||||
when 5
|
||||
messages = "截止日期之前不可启动匿评"
|
||||
end
|
||||
present :data,messages
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '关闭匿评'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :course_id,type:Integer,desc:'课程id'
|
||||
requires :homework_id,type:Integer,desc:'作业id'
|
||||
end
|
||||
post ':homework_id/stop_anonymous_comment' do
|
||||
hs = Homeworks.get_service
|
||||
hs.stop_anonymous_comment params,current_user
|
||||
message = "成功关闭"
|
||||
present :data, message
|
||||
present :status,0
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,107 +4,85 @@ module Mobile
|
|||
include Redmine::I18n
|
||||
def self.course_dynamic_expose(field)
|
||||
expose field do |c,opt|
|
||||
if field == :update_time
|
||||
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field)))
|
||||
elsif field == :news_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 1
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :document_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 3
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :topic_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 2
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :homework_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 4
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
else
|
||||
# if field == :news_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 1
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :document_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :topic_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 2
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :homework_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 4
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# else
|
||||
c[field] if (c.is_a?(Hash) && c.key?(field))
|
||||
end
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
course_dynamic_expose :type
|
||||
course_dynamic_expose :count
|
||||
course_dynamic_expose :course_name
|
||||
course_dynamic_expose :course_term
|
||||
course_dynamic_expose :course_time
|
||||
course_dynamic_expose :course_id
|
||||
course_dynamic_expose :course_img_url
|
||||
course_dynamic_expose :message
|
||||
course_dynamic_expose :update_time
|
||||
course_dynamic_expose :count
|
||||
course_dynamic_expose :news_count
|
||||
course_dynamic_expose :document_count
|
||||
course_dynamic_expose :topic_count
|
||||
course_dynamic_expose :homework_count
|
||||
#在dynamics里解析出四种动态
|
||||
expose :documents,using:Mobile::Entities::Attachment do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 3
|
||||
obj = d[:documents]
|
||||
end
|
||||
end
|
||||
obj
|
||||
end
|
||||
course_dynamic_expose :course_student_num
|
||||
course_dynamic_expose :time_from_now
|
||||
course_dynamic_expose :current_user_is_member
|
||||
course_dynamic_expose :current_user_is_teacher
|
||||
|
||||
# expose :documents,using:Mobile::Entities::Attachment do |f,opt|
|
||||
# obj = nil
|
||||
# f[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:documents]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# end
|
||||
expose :topics,using:Mobile::Entities::Message do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 2
|
||||
obj = d[:topics]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:topics]
|
||||
end
|
||||
expose :homeworks,using:Mobile::Entities::Homework do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 4
|
||||
obj = d[:homeworks]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:homeworks]
|
||||
end
|
||||
|
||||
expose :news,using:Mobile::Entities::News do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 1
|
||||
obj = d[:news]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:news]
|
||||
end
|
||||
|
||||
expose :better_students,using:Mobile::Entities::User do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 6
|
||||
obj = d[:better_students]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:better_students]
|
||||
end
|
||||
|
||||
expose :active_students,using:Mobile::Entities::User do |f,opt|
|
||||
f[:active_students]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,12 +24,19 @@ module Mobile
|
|||
f.course.members.count - f.student_works.count
|
||||
when :homework_submit_num
|
||||
f.student_works.count
|
||||
when :homework_status
|
||||
when :homework_status_student
|
||||
get_homework_status f
|
||||
when :homework_times
|
||||
f.course.homework_commons.index(f) + 1
|
||||
when :homework_status_desc
|
||||
when :homework_status_teacher
|
||||
homework_status_desc f
|
||||
when :student_evaluation_part
|
||||
get_evaluation_part f ,3
|
||||
when :ta_evaluation_part
|
||||
get_evaluation_part f , 2
|
||||
when :homework_anony_type
|
||||
val = f.homework_type == 1 && !f.homework_detail_manual.nil?
|
||||
val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -79,11 +86,13 @@ module Mobile
|
|||
homework_expose :homework_submit_num
|
||||
homework_expose :homework_notsubmit_num
|
||||
|
||||
expose :submit_student_list ,using: Mobile::Entities::User do |f,opt|
|
||||
get_submit_sutdent_list f
|
||||
end
|
||||
homework_expose :homework_status #作业的状态
|
||||
homework_expose :homework_status_desc #状态的解释
|
||||
homework_expose :homework_status_student #学生看到的作业的状态
|
||||
homework_expose :homework_status_teacher #老师看到的状态
|
||||
|
||||
homework_expose :student_evaluation_part #学生匿评比率
|
||||
homework_expose :ta_evaluation_part #教辅评价比率
|
||||
|
||||
homework_expose :homework_anony_type #是否是匿评作业
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ module Mobile
|
|||
expose :comments, using: Mobile::Entities::Comment do |f, opt|
|
||||
if f.is_a?(Hash) && f.key?(:comments)
|
||||
f[:comments]
|
||||
elsif f.is_a?(::News) && f.respond_to?(:comments)
|
||||
f.send(:comments)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ module Mobile
|
|||
user_expose :score
|
||||
#学号
|
||||
user_expose :student_num
|
||||
# 活跃值
|
||||
user_expose :active_count
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ class ActivityNotifysController < ApplicationController
|
|||
list = query.order('is_read,id desc').limit(limit).offset(@obj_pages.offset).all();
|
||||
events=[];
|
||||
for item in list
|
||||
if item.activity.nil?
|
||||
next
|
||||
end
|
||||
event = item.activity;
|
||||
event.set_notify_id(item.id)
|
||||
event.set_notify_is_read(item.is_read)
|
||||
|
|
|
|||
|
|
@ -337,6 +337,19 @@ class AdminController < ApplicationController
|
|||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#学校列表
|
||||
def schools
|
||||
@school_name = params[:school_name]
|
||||
if @school_name
|
||||
@schools = School.where("name like '%#{@school_name}%'")
|
||||
else
|
||||
@schools = School.all
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
#移动端版本管理
|
||||
def mobile_version
|
||||
@versions = PhoneAppVersion.reorder('created_at desc')
|
||||
|
|
@ -382,4 +395,74 @@ class AdminController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
#留言列表
|
||||
def leave_messages
|
||||
@jour = JournalsForMessage.where("jour_type = 'Principal' or jour_type = 'Course'").reorder('created_on desc')
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 30})
|
||||
else
|
||||
@limit = 30#per_page_option
|
||||
end
|
||||
|
||||
@jour_count = @jour.count
|
||||
@jour_pages = Paginator.new @jour_count, @limit, params['page']
|
||||
@offset ||= @jour_pages.offset
|
||||
@jour = @jour.limit(@limit).offset(@offset).all
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#帖子
|
||||
def messages_list
|
||||
@memo = Memo.reorder("created_at desc")
|
||||
|
||||
=begin
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 30})
|
||||
else
|
||||
@limit = 30#per_page_option
|
||||
end
|
||||
|
||||
@memo_count = @memo.count
|
||||
@memo_pages = Paginator.new @memo_count, @limit, params['page']
|
||||
@offset ||= @memo_pages.offset
|
||||
@memo = @memo.limit(@limit).offset(@offset).all
|
||||
=end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#课程讨论区的帖子
|
||||
def course_messages
|
||||
#@boards=Board.where('course_id is NULL')
|
||||
#@course_ms = Message.reorder('created_on desc')
|
||||
@course_ms=Message.joins("join boards on messages.board_id=boards.id where boards.course_id is not NULL").reorder('created_on desc')
|
||||
end
|
||||
|
||||
#项目讨论区的帖子
|
||||
def project_messages
|
||||
@project_ms=Message.joins("join boards on messages.board_id=boards.id where boards.project_id != -1").reorder('created_on desc')
|
||||
end
|
||||
|
||||
#通知
|
||||
def notices
|
||||
@news = News.where('course_id is not NULL').order('created_on desc')
|
||||
end
|
||||
|
||||
#最近登录用户列表
|
||||
def latest_login_users
|
||||
@user = User.order('last_login_on desc')
|
||||
end
|
||||
|
||||
#作业
|
||||
def homework
|
||||
@homework = HomeworkCommon.order('end_time desc')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -514,6 +514,8 @@ private
|
|||
end
|
||||
|
||||
def has_login
|
||||
render_403 unless User.current.logged?
|
||||
unless @attachment && @attachment.container_type == "PhoneAppVersion"
|
||||
render_403 unless User.current.logged?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@ class CoursesController < ApplicationController
|
|||
menu_item l(:label_sort_by_influence), :only => :index
|
||||
|
||||
before_filter :can_show_course, :except => []
|
||||
before_filter :logged_user_by_apptoken,:only => [:show,:new_homework,:feedback]
|
||||
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
|
||||
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
||||
before_filter :logged_user_by_apptoken,:only => [:show,:feedback]
|
||||
before_filter :find_course, :except => [ :index, :search, :new,:join,:unjoin, :create, :new_join, :course,:join_private_courses]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :update, :course]
|
||||
before_filter :authorize_course_global, :only => [:new,:create]
|
||||
before_filter :toggleCourse, :only => [:finishcourse, :restartcourse]
|
||||
|
||||
before_filter :require_login, :only => [:join, :unjoin]
|
||||
|
|
@ -40,9 +39,14 @@ class CoursesController < ApplicationController
|
|||
else
|
||||
@state = 5 #未登录
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
|
||||
end
|
||||
# if @state == 1 || @state == 3
|
||||
# respond_to course_path(course.id)
|
||||
# else
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
|
||||
end
|
||||
#end
|
||||
|
||||
rescue Exception => e
|
||||
@state = 4 #已经加入了课程
|
||||
respond_to do |format|
|
||||
|
|
@ -102,74 +106,17 @@ class CoursesController < ApplicationController
|
|||
# 课程搜索
|
||||
# add by nwb
|
||||
def search
|
||||
courses_all = Course.all_course
|
||||
name = params[:name]
|
||||
if name.blank?
|
||||
@courses = []
|
||||
@courses_all = []
|
||||
@course_count = 0
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
if params[:name].empty?
|
||||
courses = Course.visible
|
||||
@courses = paginateHelper courses,10
|
||||
else
|
||||
@courses = courses_all.visible
|
||||
if params[:name].present?
|
||||
@courses_all = @courses.like(params[:name])
|
||||
else
|
||||
@courses_all = @courses;
|
||||
end
|
||||
@course_count = @courses_all.count
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
|
||||
# 课程的动态数
|
||||
@course_activity_count=Hash.new
|
||||
@courses_all.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
end
|
||||
|
||||
case params[:course_sort_type]
|
||||
when '0'
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@s_type = 0
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '1'
|
||||
@courses = @courses_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '2'
|
||||
@courses = @courses_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '3'
|
||||
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
||||
@courses=handle_course @courses_all,@course_activity_count
|
||||
@s_type = 3
|
||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||
|
||||
else
|
||||
@s_type = 0
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
end
|
||||
courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'")
|
||||
@courses = paginateHelper courses,10
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'course_base'
|
||||
scope = Course
|
||||
unless params[:closed]
|
||||
scope = scope.active
|
||||
end
|
||||
}
|
||||
format.atom {
|
||||
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||
|
|
@ -298,7 +245,7 @@ class CoursesController < ApplicationController
|
|||
if params[:group_id] && params[:group_id] != "0"
|
||||
@group = CourseGroup.find(params[:group_id])
|
||||
@results = student_homework_score(@group.id,0, 0,"desc")
|
||||
@results = paginateHelper @results, 10
|
||||
# @results = paginateHelper @results, 10
|
||||
else
|
||||
page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1)
|
||||
@results = student_homework_score(0,page_from, 10,"desc")
|
||||
|
|
@ -368,12 +315,12 @@ class CoursesController < ApplicationController
|
|||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name)
|
||||
@result_count = @results.count
|
||||
@results = paginateHelper @results, 10
|
||||
# @results = paginateHelper @results, 10
|
||||
else
|
||||
@group = CourseGroup.find(group_id)
|
||||
@results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by),@search_name)
|
||||
@result_count = @results.count
|
||||
@results = paginateHelper @results, 10
|
||||
# @results = paginateHelper @results, 10
|
||||
end
|
||||
else
|
||||
if group_id == '0'
|
||||
|
|
@ -605,7 +552,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
def toggleCourse
|
||||
@course_prefs = Course.find_by_extra(@course.extra)
|
||||
unless (@course_prefs.teacher == User.current || User.current.admin?)
|
||||
unless (User.current.allowed_to?(:as_teacher,@course_prefs) || User.current.admin?)
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
|
@ -659,92 +606,9 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
|
||||
return
|
||||
end
|
||||
@users_by_role = @course.users_by_role
|
||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||
end
|
||||
@key = User.current.rss_key
|
||||
#新增内容
|
||||
@days = Setting.activity_days_default.to_i
|
||||
if params[:from]
|
||||
begin; @date_to = params[:from].to_date + 1; rescue; end
|
||||
end
|
||||
has = {
|
||||
"show_course_files" => true,
|
||||
"show_course_news" => true,
|
||||
"show_course_messages" => true,
|
||||
#"show_course_journals_for_messages" => true,
|
||||
# "show_bids" => true,
|
||||
# "show_homeworks" => true,
|
||||
"show_polls" => true
|
||||
}
|
||||
@date_to ||= Date.today + 1
|
||||
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
||||
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
||||
if @author.nil?
|
||||
# 显示老师和助教的活动
|
||||
# @authors = searchTeacherAndAssistant(@course)
|
||||
@authors = course_all_member(@course)
|
||||
events = []
|
||||
key = "course_events_#{@course.id}".to_sym
|
||||
if Rails.env.production? && Setting.course_cahce_enabled?
|
||||
events = Rails.cache.read(key) || []
|
||||
end
|
||||
if events.empty?
|
||||
@authors.each do |author|
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||
:with_subprojects => false,
|
||||
:author => author.user)
|
||||
|
||||
@activity.scope_select {|t| has["show_#{t}"]}
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events += @activity.events(@days, @course.created_at)
|
||||
else
|
||||
events += @activity.events(@days, @course.created_at, :is_public => 1)
|
||||
end
|
||||
end
|
||||
Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
|
||||
end
|
||||
else
|
||||
# @author = @course.teacher
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||
:with_subprojects => false,
|
||||
:author => @author)
|
||||
|
||||
@activity.scope_select {|t| has["show_#{t}"]}
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events(@days, @course.created_at)
|
||||
else
|
||||
events = @activity.events(@days, @course.created_at, :is_public => 1)
|
||||
end
|
||||
end
|
||||
|
||||
# 无新动态时,显示老动态
|
||||
if events.count == 0
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events
|
||||
else
|
||||
events = @activity.events(:is_public => 1)
|
||||
end
|
||||
end
|
||||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||
end
|
||||
|
||||
sorted_events = sort_activity_events_course(events)
|
||||
events = paginateHelper sorted_events,10
|
||||
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||
# documents
|
||||
|
||||
|
||||
course_activities = @course.course_activities.order("created_at desc")
|
||||
@canShowRealName = User.current.member_of_course? @course
|
||||
@course_activities = paginateHelper course_activities,10
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses'}
|
||||
format.api
|
||||
|
|
@ -809,6 +673,12 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#删除课程
|
||||
#删除课程只是将课程的is_delete状态改为false,is_delete为false状态的课程只有管理员可以看到
|
||||
def destroy
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def allow_join course
|
||||
if course_endTime_timeout? course
|
||||
|
|
@ -838,7 +708,7 @@ class CoursesController < ApplicationController
|
|||
sql_select = ""
|
||||
if groupid == 0
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT AVG(student_works.final_score)
|
||||
SELECT SUM(student_works.final_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{@course.id}
|
||||
|
|
@ -850,7 +720,7 @@ class CoursesController < ApplicationController
|
|||
WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}"
|
||||
else
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT AVG(student_works.final_score)
|
||||
SELECT SUM(student_works.final_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{@course.id}
|
||||
|
|
|
|||
|
|
@ -177,11 +177,11 @@ class FilesController < ApplicationController
|
|||
def index
|
||||
@flag = params[:flag] || false
|
||||
#sort_init 'filename', 'asc'
|
||||
sort_init 'created_on', 'desc'
|
||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
'filename' => "#{Attachment.table_name}.filename",
|
||||
'size' => "#{Attachment.table_name}.filesize",
|
||||
'downloads' => "#{Attachment.table_name}.downloads"
|
||||
# sort_init 'created_on', 'desc'
|
||||
# sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
# 'filename' => "#{Attachment.table_name}.filename",
|
||||
# 'size' => "#{Attachment.table_name}.filesize",
|
||||
# 'downloads' => "#{Attachment.table_name}.downloads"
|
||||
sort = ""
|
||||
@sort = ""
|
||||
@order = ""
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class ForumsController < ApplicationController
|
|||
order(sort_clause).
|
||||
preload(:author, {:last_reply => :author}).
|
||||
all
|
||||
|
||||
@memos
|
||||
flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
|
||||
# back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
|
||||
format.html { render action: :show, layout: 'base_forums' }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
|
||||
|
|
@ -122,14 +122,14 @@ class ForumsController < ApplicationController
|
|||
@topic_count = @forum.topics.count
|
||||
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
|
||||
@memos = @forum.topics.
|
||||
reorder("#{Memo.table_name}.sticky DESC").
|
||||
# reorder("#{Memo.table_name}.sticky DESC").
|
||||
includes(:last_reply).
|
||||
limit(@topic_pages.per_page).
|
||||
offset(@topic_pages.offset).
|
||||
order(sort_clause).
|
||||
preload(:author, {:last_reply => :author}).
|
||||
all
|
||||
|
||||
@memos
|
||||
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
# @forum = Forum.find(params[:id])
|
||||
# @memos_all = @forum.topics
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
class HomeworkCommonController < ApplicationController
|
||||
require 'net/http'
|
||||
require 'json'
|
||||
require "base64"
|
||||
layout "base_courses"
|
||||
before_filter :find_course, :only => [:index,:new,:create]
|
||||
before_filter :find_course, :only => [:index,:new,:create,:next_step]
|
||||
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
|
||||
before_filter :member_of_course, :only => [:index]
|
||||
|
|
@ -16,20 +19,59 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@homework_type = "1"
|
||||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 0
|
||||
@homework.late_penalty = 2
|
||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
|
||||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 0
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.homework_detail_manual = @homework_detail_manual
|
||||
if @homework_type == "1"
|
||||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 2
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.homework_detail_manual = @homework_detail_manual
|
||||
elsif @homework_type == "2"
|
||||
#编程作业相关属性
|
||||
@homework_detail_programing = HomeworkDetailPrograming.new
|
||||
@homework.homework_detail_programing = @homework_detail_programing
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#新建作业下一步
|
||||
def next_step
|
||||
@homework_type = params[:homework_common_type]
|
||||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 2
|
||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
|
||||
if @homework_type == "1"
|
||||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 2
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.homework_detail_manual = @homework_detail_manual
|
||||
elsif @homework_type == "2"
|
||||
#编程作业相关属性
|
||||
@homework_detail_programing = HomeworkDetailPrograming.new
|
||||
@homework.homework_detail_programing = @homework_detail_programing
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
|
|
@ -50,17 +92,63 @@ class HomeworkCommonController < ApplicationController
|
|||
homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(homework)
|
||||
|
||||
#匿评作业相关属性
|
||||
homework_detail_manual = HomeworkDetailManual.new
|
||||
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_detail_manual.comment_status = 1
|
||||
homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
homework.homework_detail_manual = homework_detail_manual
|
||||
if homework.homework_type == 2
|
||||
homework_detail_programing = HomeworkDetailPrograming.new
|
||||
homework_detail_programing.language = params[:language]
|
||||
homework_detail_programing.standard_code = params[:standard_code]
|
||||
homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||
question = {title:homework.name,content:homework.description}
|
||||
question[:input] = []
|
||||
question[:output] = []
|
||||
if params[:input] && params[:output] && params[:result]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
homework.homework_tests << homework_test
|
||||
question[:input] << homework_test.input
|
||||
question[:output] << homework_test.output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# uri = URI('http://test.gitlab.trustie.net/api/questions.json')
|
||||
# req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})
|
||||
# req.body = question.to_json
|
||||
# res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
||||
# http.request(req)
|
||||
# end
|
||||
|
||||
uri = URI('http://192.168.80.21:8080/api/questions.json')
|
||||
body = question.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
||||
|
||||
homework.homework_detail_programing = homework_detail_programing
|
||||
else
|
||||
#匿评作业相关属性
|
||||
homework_detail_manual = HomeworkDetailManual.new
|
||||
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_detail_manual.comment_status = 1
|
||||
homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
homework.homework_detail_manual = homework_detail_manual
|
||||
end
|
||||
|
||||
if homework.save
|
||||
homework_detail_programing.save if homework_detail_programing
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
|
@ -90,7 +178,7 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework.description = params[:homework_common][:description]
|
||||
@homework.end_time = params[:homework_common][:end_time]
|
||||
@homework.publish_time = params[:homework_common][:publish_time]
|
||||
@homework.homework_type = params[:homework_common][:homework_type]
|
||||
@homework.homework_type = params[:homework_common][:homework_type] if params[:homework_common][:homework_type]
|
||||
unless @homework.late_penalty == params[:late_penalty]
|
||||
@homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work|
|
||||
student_work.late_penalty = params[:late_penalty]
|
||||
|
|
@ -98,10 +186,10 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
@homework.late_penalty = params[:late_penalty]
|
||||
end
|
||||
@homework.course_id = @course.id
|
||||
# @homework.course_id = @course.id
|
||||
|
||||
#匿评作业相关属性
|
||||
if @homework.homework_type == 1
|
||||
if @homework.homework_type == 1 && @homework_detail_manual
|
||||
@homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
@homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
@homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
|
|
@ -117,18 +205,72 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
@homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
end
|
||||
else #不是匿评作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业
|
||||
elsif @homework.homework_type == 0 #普通作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业
|
||||
@homework.student_works.where("absence_penalty != 0").each do |student_work|
|
||||
student_work.late_penalty = 0
|
||||
student_work.save
|
||||
end
|
||||
@homework_detail_manual.absence_penalty = 0
|
||||
@homework_detail_manual.absence_penalty = 0 if @homework_detail_manual
|
||||
end
|
||||
|
||||
if @homework.homework_type == 2 && @homework_detail_programing #编程作业
|
||||
@homework_detail_programing.language = params[:language]
|
||||
@homework_detail_programing.standard_code = params[:standard_code]
|
||||
@homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_tests = @homework.homework_tests
|
||||
#需要删除的测试
|
||||
ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i)
|
||||
ids.each do |id|
|
||||
homework_test = HomeworkTest.find id
|
||||
homework_test.destroy if homework_test
|
||||
end
|
||||
if params[:input] && params[:output] && params[:result]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
homework_test = HomeworkTest.find_by_id k
|
||||
if homework_test #已存在的测试,修改
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
else #不存在的测试,增加
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
homework_test.homework_common = @homework
|
||||
end
|
||||
homework_test.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#发送修改作业的请求
|
||||
question = {title:@homework.name,content:@homework.description}
|
||||
question[:input] = []
|
||||
question[:output] = []
|
||||
@homework.homework_tests.each do |test|
|
||||
question[:input] << test.input
|
||||
question[:output] << test.output
|
||||
end
|
||||
uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json")
|
||||
body = question.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Put.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
end
|
||||
|
||||
@homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@homework)
|
||||
|
||||
if @homework.save && @homework_detail_manual.save
|
||||
if @homework.save
|
||||
@homework_detail_manual.save if @homework_detail_manual
|
||||
@homework_detail_programing.save if @homework_detail_programing
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_edit)
|
||||
|
|
@ -216,6 +358,24 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def programing_test
|
||||
test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
|
||||
@index = params[:index]
|
||||
uri = URI('http://192.168.80.21:8080/api/realtime.json')
|
||||
body = test.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
@err_msg = result["compile_error_msg"]
|
||||
result["results"].each do |re|
|
||||
@result = re["status"]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取课程
|
||||
def find_course
|
||||
|
|
@ -227,6 +387,7 @@ class HomeworkCommonController < ApplicationController
|
|||
def find_homework
|
||||
@homework = HomeworkCommon.find params[:id]
|
||||
@homework_detail_manual = @homework.homework_detail_manual
|
||||
@homework_detail_programing = @homework.homework_detail_programing
|
||||
@course = @homework.course
|
||||
rescue
|
||||
render_404
|
||||
|
|
|
|||
|
|
@ -112,7 +112,19 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
|
||||
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
|
||||
query = @issue.forge_messages
|
||||
if User.current.id == @issue.assigned_to_id
|
||||
query.update_all(:viewed => true)
|
||||
end
|
||||
# 缺陷状态更新
|
||||
query_journals = @issue.journals
|
||||
if User.current.id == @issue.author_id
|
||||
query_journals.each do |query_journal|
|
||||
query_journal.forge_messages.update_all(:viewed => true)
|
||||
end
|
||||
end
|
||||
#
|
||||
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
|
||||
@journals.each_with_index {|j,i| j.indice = i+1}
|
||||
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class MyController < ApplicationController
|
|||
helper :issues
|
||||
helper :users
|
||||
helper :custom_fields
|
||||
helper :user_score
|
||||
|
||||
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
||||
'issuesreportedbyme' => :label_reported_issues,
|
||||
|
|
@ -88,6 +89,23 @@ class MyController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def clear_user_avatar_temp
|
||||
@user = User.current
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
diskfile1 = diskfile + 'temp'
|
||||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
def save_user_avatar
|
||||
@user = User.current
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
diskfile1 = diskfile + 'temp'
|
||||
begin
|
||||
FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
|
||||
ensure
|
||||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
end
|
||||
|
||||
# Edit user's account
|
||||
def account
|
||||
@user = User.current
|
||||
|
|
@ -119,6 +137,8 @@ class MyController < ApplicationController
|
|||
@se.identity = params[:identity].to_i if params[:identity]
|
||||
@se.technical_title = params[:technical_title] if params[:technical_title]
|
||||
@se.student_id = params[:no] if params[:no]
|
||||
@se.brief_introduction = params[:brief_introduction]
|
||||
@se.description = params[:description]
|
||||
|
||||
if @user.save && @se.save
|
||||
# 头像保存
|
||||
|
|
@ -137,6 +157,7 @@ class MyController < ApplicationController
|
|||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
# Destroys user's account
|
||||
|
|
@ -159,6 +180,8 @@ class MyController < ApplicationController
|
|||
|
||||
# Manage user's password
|
||||
def password
|
||||
begin
|
||||
@act='password'
|
||||
@user = User.current
|
||||
unless @user.change_password_allowed?
|
||||
flash.now[:error] = l(:notice_can_t_change_password)
|
||||
|
|
@ -174,16 +197,20 @@ class MyController < ApplicationController
|
|||
Token.delete_user_all_tokens(@user)
|
||||
logout_user
|
||||
redirect_to signin_url(back_url: my_account_path)
|
||||
return
|
||||
else
|
||||
flash.now[:error] = l(:notice_account_wrong_password)
|
||||
#flash.now[:error] = l(:notice_account_wrong_password)
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == 'wrong password'
|
||||
flash.now[:error] = l(:notice_account_wrong_password)
|
||||
# flash.now[:error] = l(:notice_account_wrong_password)
|
||||
else
|
||||
flash.now[:error] = e.message
|
||||
# flash.now[:error] = e.message
|
||||
end
|
||||
flash.now[:error] = l(:notice_account_old_wrong_password)
|
||||
end
|
||||
render :template => 'my/account',:layout=>'base_users_new'
|
||||
end
|
||||
|
||||
# Create a new feeds key
|
||||
|
|
|
|||
|
|
@ -71,10 +71,15 @@ class NewsController < ApplicationController
|
|||
scope = @course ? @course.news.course_visible : News.course_visible
|
||||
|
||||
@news_count = scope.count
|
||||
#@news_pages = Paginator.new @news_count, @limit, params['page']
|
||||
#@offset ||= scope_page.offset
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
@q = params[:subject]
|
||||
if params[:subject].nil? || params[:subject].blank?
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
else
|
||||
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
end
|
||||
|
||||
# :offset => @offset,
|
||||
# :limit => @limit)
|
||||
@newss = paginateHelper scope_order,10
|
||||
|
|
@ -83,6 +88,7 @@ class NewsController < ApplicationController
|
|||
@news = News.new
|
||||
render :layout => 'base_courses'
|
||||
}
|
||||
format.js
|
||||
format.api
|
||||
format.atom { render_feed(@newss, :title => (@course ? @course.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
||||
end
|
||||
|
|
@ -141,7 +147,7 @@ class NewsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
|
||||
teachers = searchTeacherAndAssistant(@course)
|
||||
for teacher in teachers
|
||||
if(teacher.user_id != User.current.id)
|
||||
|
|
@ -155,7 +161,7 @@ class NewsController < ApplicationController
|
|||
notify.save()
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
|
||||
render_attachment_warning_if_needed(@news)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to course_news_index_url(@course)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class OrganizationController < ApplicationController
|
||||
layout 'base_projects'
|
||||
# layout 'base_projects'
|
||||
before_filter :require_admin, :except => [:index]
|
||||
|
||||
def index
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#encoding utf-8
|
||||
class PollController < ApplicationController
|
||||
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll]
|
||||
before_filter :find_container, :only => [:new,:create, :index]
|
||||
|
|
@ -23,7 +24,7 @@ class PollController < ApplicationController
|
|||
|
||||
def show
|
||||
@poll = Poll.find params[:id]
|
||||
if @poll.polls_status != 2 && !User.current.allowed_to?(:as_teacher,@course)
|
||||
if @poll.polls_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)
|
||||
render_403
|
||||
return
|
||||
end
|
||||
|
|
@ -137,11 +138,19 @@ class PollController < ApplicationController
|
|||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
end
|
||||
if @poll_questions.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
# 如果是插入的话,那么从插入的这个id以后的question_num都将要+1
|
||||
if params[:quest_id]
|
||||
@is_insert = true
|
||||
@poll.poll_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1")
|
||||
@poll_question_num = params[:quest_num].to_i
|
||||
@poll_questions.question_number = params[:quest_num].to_i + 1
|
||||
end
|
||||
if @poll_questions.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#修改题目
|
||||
|
|
@ -328,6 +337,37 @@ class PollController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def import_poll
|
||||
@poll = Poll.find(params[:to_id])
|
||||
question_num = @poll.poll_questions.select("max(question_number) question_number").first.question_number
|
||||
import_poll = Poll.find(params[:import_id])
|
||||
import_poll.poll_questions.each_with_index do |question,index|
|
||||
option = {
|
||||
:is_necessary => question.is_necessary,
|
||||
:question_title => question.question_title,
|
||||
:question_type => question.question_type,
|
||||
:question_number => question_num + index+1
|
||||
}
|
||||
poll_questions = @poll.poll_questions.new option
|
||||
for i in 1..question.poll_answers.count
|
||||
answer = question.poll_answers[i-1][:answer_text]
|
||||
question_option = {
|
||||
:answer_position => i,
|
||||
:answer_text => answer
|
||||
}
|
||||
poll_questions.poll_answers.new question_option
|
||||
end
|
||||
@poll.poll_questions << poll_questions
|
||||
end
|
||||
if @poll.save
|
||||
@poll = Poll.find(params[:to_id])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#重新发布问卷
|
||||
def republish_poll
|
||||
@poll.poll_questions.each do |poll_question|
|
||||
|
|
@ -371,6 +411,70 @@ class PollController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 将其他地方的问卷导出来
|
||||
def other_poll
|
||||
# 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入
|
||||
tea_ids = '('
|
||||
tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
|
||||
@polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
|
||||
@polls_group_id = params[:polls_group_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 将问卷导入本课程
|
||||
def import_other_poll
|
||||
course_id = params[:course_id]
|
||||
@course = Course.find(course_id)
|
||||
params[:polls].each_with_index do |p,i|
|
||||
poll = Poll.find(p)
|
||||
option = {
|
||||
:polls_name => poll.polls_name || l(:label_poll_new),
|
||||
:polls_type => 'Course',
|
||||
:polls_group_id => course_id,
|
||||
:polls_status => 1,
|
||||
:user_id => User.current.id,
|
||||
:published_at => Time.now,
|
||||
:closed_at => Time.now,
|
||||
:show_result => 1,
|
||||
:polls_description => poll.polls_description
|
||||
}
|
||||
@poll = Poll.create option
|
||||
|
||||
poll.poll_questions.each do | q|
|
||||
#question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
||||
option = {
|
||||
:is_necessary => q[:is_necessary],
|
||||
:question_title => q[:question_title],
|
||||
:question_type => q[:question_type] || 1,
|
||||
:question_number => q[:question_number]
|
||||
}
|
||||
@poll_questions = @poll.poll_questions.new option
|
||||
|
||||
for i in 1..q.poll_answers.count
|
||||
answer = q.poll_answers[i-1].nil? ? l(:label_new_answer) : q.poll_answers[i-1][:answer_text]
|
||||
question_option = {
|
||||
:answer_position => i,
|
||||
:answer_text => answer
|
||||
}
|
||||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
end
|
||||
@poll.save
|
||||
end
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
if @is_teacher
|
||||
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
|
||||
else
|
||||
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
|
||||
end
|
||||
@polls = paginateHelper polls,20 #分页
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_poll_and_course
|
||||
@poll = Poll.find params[:id]
|
||||
|
|
@ -393,7 +497,7 @@ class PollController < ApplicationController
|
|||
end
|
||||
|
||||
def is_member_of_course
|
||||
render_403 unless(@course && User.current.member_of_course?(@course))
|
||||
render_403 unless(@course && (User.current.member_of_course?(@course) || User.current.admin?))
|
||||
end
|
||||
|
||||
def is_course_teacher
|
||||
|
|
|
|||
|
|
@ -86,8 +86,14 @@ class ProjectsController < ApplicationController
|
|||
@project_pages = Project.project_entities.visible.like(params[:name]).page(params[:page]).per(10)
|
||||
else
|
||||
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
|
||||
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
|
||||
end
|
||||
@projects = @project_pages.order("created_on desc")
|
||||
@limit = 10#per_page_option
|
||||
|
||||
@project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
|
||||
@project_pages = Paginator.new @project_count, @limit, params['page']
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
|
|
@ -150,11 +156,15 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
render :layout => 'base'
|
||||
if User.current.login?
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
render :layout => 'base'
|
||||
else
|
||||
redirect_to signin_url
|
||||
end
|
||||
end
|
||||
|
||||
def share
|
||||
|
|
@ -167,6 +177,10 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
unless User.current.login?
|
||||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
|
|
@ -280,11 +294,11 @@ class ProjectsController < ApplicationController
|
|||
|
||||
# 根据私密性,取出符合条件的所有数据
|
||||
if User.current.member_of?(@project) || User.current.admin?
|
||||
@events_pages = ForgeActivity.where("project_id = ?",@project).order("created_at desc").page(params['page'|| 1]).per(20);
|
||||
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type != ?",@project, "Document" ).order("created_at desc").page(params['page'|| 1]).per(20);
|
||||
#events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
|
||||
= ?",@project,1).order("created_at desc")
|
||||
= ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc")
|
||||
.page(params['page'|| 1]).per(10);
|
||||
# @events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -249,6 +249,14 @@ update
|
|||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
if params[:to] == 'gitlab'
|
||||
g = Gitlab.client
|
||||
g.post('/session', body: {email: User.current.mail, password: User.current.hashed_password})
|
||||
redirect_to "http://192.168.41.130:3000/gitlab-org/gitlab-shell/tree/master"
|
||||
return
|
||||
end
|
||||
|
||||
#if( !User.current.member_of?(@project) || @project.hidden_repo)
|
||||
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||
|
||||
|
|
@ -441,6 +449,8 @@ update
|
|||
def stats
|
||||
@project_id = params[:id]
|
||||
@repository_id = @repository.identifier
|
||||
# 提交次数统计
|
||||
@status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id])
|
||||
render :layout => 'base_projects'
|
||||
end
|
||||
|
||||
|
|
@ -451,6 +461,12 @@ update
|
|||
data = graph_commits_per_month(@repository)
|
||||
when "commits_per_author"
|
||||
data = graph_commits_per_author(@repository)
|
||||
when "author_commits_per_month"
|
||||
data = graph_author_commits_per_month(@repository)
|
||||
when "author_commits_six_month"
|
||||
data = author_commits_six_month(@repository)
|
||||
when "author_code_six_months"
|
||||
data = author_code_six_month(@repository)
|
||||
end
|
||||
if data
|
||||
headers["Content-Type"] = "image/svg+xml"
|
||||
|
|
@ -476,7 +492,18 @@ update
|
|||
if params[:repository_id].present?
|
||||
@repository = @project.repositories.find_by_identifier_param(params[:repository_id])
|
||||
else
|
||||
@repository = @project.repository
|
||||
# 多版本库,如果一个版本库为空则去下一个
|
||||
rep_count = @project.repositories.count
|
||||
if @project.repository.nil?
|
||||
for i in 0..rep_count
|
||||
unless @project.repositories[i].nil?
|
||||
@repository = @project.repositories[i]
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
@repository = @project.repository
|
||||
end
|
||||
end
|
||||
(render_404; return false) unless @repository
|
||||
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
|
||||
|
|
@ -540,11 +567,12 @@ update
|
|||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:step_x_labels => 2,
|
||||
:show_data_values => false,
|
||||
:show_data_values => true,
|
||||
:graph_title => l(:label_commits_per_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
|
||||
# 具状图
|
||||
graph.add_data(
|
||||
:data => commits_by_month[0..11].reverse,
|
||||
:title => l(:label_revision_plural)
|
||||
|
|
@ -560,7 +588,7 @@ update
|
|||
|
||||
def graph_commits_per_author(repository)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
|
||||
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
|
||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||
|
|
@ -582,7 +610,7 @@ update
|
|||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => false,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_commits_per_author),
|
||||
:show_graph_title => true
|
||||
|
|
@ -597,6 +625,123 @@ update
|
|||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户最近一年的提交次数
|
||||
def graph_author_commits_per_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 12
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer,
|
||||
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_commits_year),
|
||||
:show_graph_title => true,
|
||||
:no_css => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_commit_count)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户最近六个月的提交次数
|
||||
def author_commits_six_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 6
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer,
|
||||
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_commits_six_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_commit_count)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 最近六个月代码量统计
|
||||
def author_code_six_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 6
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
|
||||
commits_by_author = Changeset.count(:group => :committer, :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40)
|
||||
all_author = []
|
||||
commits_by_author.each do |cba|
|
||||
all_author << cba.first
|
||||
end
|
||||
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
|
||||
all_author = all_author.collect {|c| c.split.first }
|
||||
commits_by_author = repository.commits(all_author, "#{@date_from}", "#{@date_to}", repository.id == 150 ? "szzh" : 'master')
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_code_six_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:lable_revision_code_count)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
|
||||
def check_hidden_repo
|
||||
project = Project.find(params[:id])
|
||||
if !User.current.member_of?(project)
|
||||
|
|
|
|||
|
|
@ -4,28 +4,21 @@ class SchoolController < ApplicationController
|
|||
|
||||
def upload
|
||||
uploaded_io = params[:logo]
|
||||
school_id = 0
|
||||
schools = School.where("name = ?", params[:school])
|
||||
|
||||
schools.each do |s|
|
||||
school_id = s.id
|
||||
end
|
||||
|
||||
school_id ||= params[:id]
|
||||
unless uploaded_io.nil?
|
||||
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
|
||||
file.write(uploaded_io.read)
|
||||
end
|
||||
|
||||
s1 = School.find(school_id)
|
||||
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
|
||||
s1.save
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
redirect_to admin_schools_url(:school_name => params[:school_name])
|
||||
end
|
||||
|
||||
def upload_logo
|
||||
|
||||
@school = School.find params[:id]
|
||||
@school_name = params[:school_name]
|
||||
end
|
||||
|
||||
#获取制定学校开设的课程数
|
||||
|
|
|
|||
|
|
@ -2,47 +2,88 @@ class StudentWorkController < ApplicationController
|
|||
layout "base_courses"
|
||||
include StudentWorkHelper
|
||||
require 'bigdecimal'
|
||||
require "base64"
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
||||
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
|
||||
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
|
||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
||||
protect_from_forgery :except => :set_program_score
|
||||
|
||||
def index
|
||||
@order,@b_sort,@name = params[:order] || "score",params[:sort] || "desc",params[:name] || ""
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
@show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
|
||||
my_work = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
course_group = CourseGroup.find_by_id(@group) if @group
|
||||
if course_group
|
||||
group_students = course_group.users
|
||||
if group_students.empty?
|
||||
student_in_group = '(0)'
|
||||
else
|
||||
student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
|
||||
end
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
@show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
|
||||
@is_evaluation = true
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
@stundet_works = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
|
||||
@is_evaluation = true
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
else
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
@show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
|
||||
@is_evaluation = true
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
@ -80,7 +121,24 @@ class StudentWorkController < ApplicationController
|
|||
stundet_work.late_penalty = 0
|
||||
end
|
||||
render_attachment_warning_if_needed(stundet_work)
|
||||
|
||||
if stundet_work.save
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
|
||||
url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
|
||||
solutions = {
|
||||
student_work_id:stundet_work.id,
|
||||
src:Base64.encode64(stundet_work.description),
|
||||
language:@homework.homework_detail_programing.language
|
||||
}
|
||||
uri = URI(url)
|
||||
body = solutions.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
|
@ -99,8 +157,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
respond_to do |format|
|
||||
format.html
|
||||
if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业
|
||||
render_403
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -135,7 +197,9 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
if @work.destroy
|
||||
if @homework.homework_type == 2 #编程作业,作品提交后不可以删除
|
||||
render_403
|
||||
elsif @work.destroy
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to student_work_index_url(:homework => @homework.id)
|
||||
|
|
@ -154,6 +218,12 @@ class StudentWorkController < ApplicationController
|
|||
if @score
|
||||
@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?
|
||||
@score.reviewer_role = 1
|
||||
else
|
||||
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
@score.reviewer_role = get_role_by_name(role)
|
||||
end
|
||||
@is_new = false
|
||||
else
|
||||
@score = StudentWorksScore.new
|
||||
|
|
@ -161,8 +231,12 @@ class StudentWorkController < ApplicationController
|
|||
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
@score.user_id = User.current.id
|
||||
@score.student_work_id = @work.id
|
||||
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
User.current.admin? ? @score.reviewer_role = 1 : @score.reviewer_role = get_role_by_name(role)
|
||||
if User.current.admin?
|
||||
@score.reviewer_role = 1
|
||||
else
|
||||
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
@score.reviewer_role = get_role_by_name(role)
|
||||
end
|
||||
@is_new = true
|
||||
end
|
||||
|
||||
|
|
@ -180,8 +254,10 @@ class StudentWorkController < ApplicationController
|
|||
if @work.student_score.nil?
|
||||
@work.final_score = @work.teaching_asistant_score
|
||||
else
|
||||
final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}"))
|
||||
ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual
|
||||
ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing
|
||||
final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
@work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
|
|
@ -303,6 +379,46 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#设置编程作业得分
|
||||
def set_program_score
|
||||
stundet_work = StudentWork.find_by_id params[:student_work_id]
|
||||
@course = stundet_work.homework_common.course
|
||||
student_score_count = 0
|
||||
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
|
||||
homework_common = stundet_work.homework_common
|
||||
params[:results].each do |result|
|
||||
homework_tests = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'")
|
||||
homework_tests.each do |homework_test|
|
||||
student_work_test = StudentWorkTest.new
|
||||
student_work_test.student_work = stundet_work
|
||||
student_work_test.homework_test = homework_test
|
||||
student_work_test.result = result[:status]
|
||||
if student_work_test.result == 0
|
||||
student_score_count += 1
|
||||
end
|
||||
student_work_test.error_msg = params[:compile_error_msg]
|
||||
student_work_test.save!
|
||||
end
|
||||
end
|
||||
unless homework_common.homework_tests.empty?
|
||||
stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count
|
||||
|
||||
if stundet_work.teacher_score.nil?
|
||||
if stundet_work.teaching_asistant_score.nil?
|
||||
stundet_work.final_score = stundet_work.student_score
|
||||
else
|
||||
final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
stundet_work.final_score = format("%.1f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
|
||||
stundet_work.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取作业
|
||||
def find_homework
|
||||
|
|
@ -329,7 +445,7 @@ class StudentWorkController < ApplicationController
|
|||
#判断是不是当前作品的提交者
|
||||
#提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
|
||||
def author_of_work
|
||||
render_403 unless (User.current.id == @work.user_id || User.current.admin?) && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||
render_403 unless User.current.admin? || (User.current.id == @work.user_id && @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||
end
|
||||
|
||||
def teacher_of_course
|
||||
|
|
@ -352,22 +468,60 @@ class StudentWorkController < ApplicationController
|
|||
sheet1 = book.create_worksheet :name => "homework"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.final_score.nil? ? l(:label_without_score) : format("%.2f",homework.final_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
if @homework.homework_type == 0 #普通作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
# sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,8] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,9] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
elsif @homework.homework_type == 1 #匿评作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
elsif @homework.homework_type == 2 #编程作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ class UsersController < ApplicationController
|
|||
menu_item :user_homework, :only => :user_homeworks
|
||||
menu_item :user_project, :only => [:user_projects, :watch_projects]
|
||||
# menu_item :requirement_focus, :only => :watch_bids
|
||||
menu_item :requirement_focus, :only => :watch_contests
|
||||
menu_item :requirement_focus, :only => :watch_contests
|
||||
menu_item :user_newfeedback, :only => :user_newfeedback
|
||||
|
||||
|
||||
menu_item :user_messages, :only => :user_messages
|
||||
|
||||
|
||||
#Ended by young
|
||||
|
||||
# edit
|
||||
|
|
@ -39,23 +40,28 @@ class UsersController < ApplicationController
|
|||
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
|
||||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index]
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index]
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
#before_filter :rest_user_score, only: :show
|
||||
#before_filter :select_entry, only: :user_projects
|
||||
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
|
||||
|
||||
|
||||
#william
|
||||
before_filter :require_login, :only => [:tag_save,:tag_saveEx]
|
||||
#before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback]
|
||||
|
||||
|
||||
#visitor
|
||||
before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist]
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :custom_fields
|
||||
|
|
@ -76,6 +82,9 @@ class UsersController < ApplicationController
|
|||
|
||||
# fq
|
||||
helper :words
|
||||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
|
||||
def refresh_changests
|
||||
if !(@user.nil?) && !(@user.memberships.nil?)
|
||||
|
|
@ -87,6 +96,41 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 用户消息
|
||||
def user_messages
|
||||
unless User.current.logged?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
# 当前用户查看消息,则设置消息为已读
|
||||
querys = @user.course_messages
|
||||
if User.current.id == @user.id
|
||||
querys.update_all(:viewed => true)
|
||||
end
|
||||
if @user.course_messages
|
||||
if params[:type].nil?
|
||||
@user_course_messages = @user.course_messages
|
||||
@user_project_messges = @user.forge_messages
|
||||
else
|
||||
case params[:type]
|
||||
when 'homework'
|
||||
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "HomeworkCommon"}
|
||||
#@user_course_messages = ForgeMessage.find_by_sql("select * from course_messages where user_id='#{@user.id}' and course_message_type = 'HomeworkCommon' order by created_at desc;")
|
||||
when 'message'
|
||||
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "Message"}
|
||||
when 'news'
|
||||
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "News"}
|
||||
when 'poll'
|
||||
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "Poll"}
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{render :layout=>'base_users_new'}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def user_projects_index
|
||||
if User.current.admin?
|
||||
memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first
|
||||
|
|
@ -104,27 +148,22 @@ class UsersController < ApplicationController
|
|||
|
||||
#added by young
|
||||
def user_projects
|
||||
|
||||
if User.current.admin?
|
||||
@memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
|
||||
else
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
@memberships = @user.memberships.all(:conditions => cond)
|
||||
end
|
||||
#events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
|
||||
#@events_by_day = events.group_by(&:event_date)
|
||||
@state = 0
|
||||
#add by huang
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
render_404
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc")
|
||||
if(params[:status] == '1')
|
||||
projects = projects.where("projects.user_id = ?",@user.id)
|
||||
elsif(params[:status] == '2')
|
||||
projects = projects.where("projects.user_id <> ?",@user.id)
|
||||
end
|
||||
@list = paginateHelper projects,10
|
||||
@params = params[:status]
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.html{render :layout=>'base_users_new'}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
|
@ -161,21 +200,21 @@ class UsersController < ApplicationController
|
|||
# format.api
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
#new add by linchun
|
||||
def watch_contests
|
||||
@bids = Contest.watched_by(@user)
|
||||
def watch_contests
|
||||
@bids = Contest.watched_by(@user)
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@contest_count = @contests.count
|
||||
@contest_pages = Paginator.new @contest_count, @limit, params['page']
|
||||
@offset ||= @contest_pages.reverse_offset
|
||||
@offset ||= @contest_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@contest = @contests.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @bid_count % @limit
|
||||
@contest = @contests.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_users'
|
||||
|
|
@ -212,9 +251,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
# end
|
||||
|
||||
|
||||
# added by huang
|
||||
def user_homeworks
|
||||
def user_homeworks
|
||||
# @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
# @memberships = []
|
||||
# @membership.each do |membership|
|
||||
|
|
@ -233,67 +272,42 @@ class UsersController < ApplicationController
|
|||
# return
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
include CoursesHelper
|
||||
def user_courses
|
||||
def user_courses
|
||||
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
if !@user.active?
|
||||
render_404
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
|
||||
if User.current == @user || User.current.admin?
|
||||
membership = @user.coursememberships.all
|
||||
else
|
||||
membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
|
||||
if(params[:status] == '1')
|
||||
courses = courses.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now)
|
||||
elsif(params[:status] == '2')
|
||||
courses = courses.where("endup_time < ?",Time.now)
|
||||
end
|
||||
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
@memberships = []
|
||||
membership.collect { |e|
|
||||
@memberships.push(e)
|
||||
}
|
||||
## 判断课程是否过期 [需封装]
|
||||
@memberships_doing = []
|
||||
@memberships_done = []
|
||||
#now_time = Time.now.year
|
||||
@memberships.map { |e|
|
||||
#end_time = e.course.get_time.year
|
||||
isDone = course_endTime_timeout?(e.course)
|
||||
if isDone
|
||||
@memberships_done.push e
|
||||
else
|
||||
@memberships_doing.push e
|
||||
end
|
||||
}
|
||||
# respond_to do |format|
|
||||
# format.html
|
||||
# format.api
|
||||
# end
|
||||
@list = paginateHelper courses,10
|
||||
@params = params[:status]
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
# modified by fq
|
||||
def user_newfeedback
|
||||
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jours.update_all(:is_readed => true, :status => false)
|
||||
@jours.each do |journal|
|
||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||
jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
if User.current == @user
|
||||
jours.update_all(:is_readed => true, :status => false)
|
||||
jours.each do |journal|
|
||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||
end
|
||||
end
|
||||
|
||||
#@limit = 10
|
||||
#@feedback_count = @jours.count
|
||||
#@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
#@offset ||= @feedback_pages.offset
|
||||
@jour = paginateHelper @jours,10
|
||||
@jour = paginateHelper jours,10
|
||||
@state = false
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
# end
|
||||
|
||||
def user_comments
|
||||
|
||||
|
|
@ -301,7 +315,7 @@ class UsersController < ApplicationController
|
|||
|
||||
#end
|
||||
def index
|
||||
|
||||
|
||||
@status = params[:status] || 1
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
|
@ -317,7 +331,7 @@ class UsersController < ApplicationController
|
|||
# 先内连一下statuses 保证排序之后数量一致
|
||||
scope = User.visible.
|
||||
joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
|
||||
|
||||
|
||||
# unknow
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
|
||||
|
|
@ -354,7 +368,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# limit and offset
|
||||
@users = @users.limit(@user_pages.per_page).offset(@user_pages.offset)
|
||||
|
||||
|
||||
@user_base_tag = params[:id] ? 'base_users':'users_base'
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
|
@ -364,7 +378,7 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def search
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
|
@ -408,8 +422,122 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def user_courses4show
|
||||
query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
|
||||
query = query.where("m.user_id = ?",@user.id).order("#{Course.table_name}.id desc")
|
||||
if User.current == @user #看自己
|
||||
else
|
||||
if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师
|
||||
query = query.joins("join member_roles r on m.id = r.member_id")
|
||||
query = query.where("r.role_id in(3,7,9)")
|
||||
end
|
||||
query = query.where(Course.table_name+".is_public = 1")
|
||||
end
|
||||
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where(" #{Course.table_name}.id < ?",params[:lastid],)
|
||||
end
|
||||
@list = query.limit(8)
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
def user_projects4show
|
||||
query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
|
||||
query = query.where("m.user_id = ? and #{Project.table_name}.project_type=?",@user.id,Project::ProjectType_project)
|
||||
if User.current == @user #看自己
|
||||
else
|
||||
query = query.where(Project.table_name+".is_public = 1")
|
||||
# TODO or exists (select 1 from project c2,members m2 where c2.id=m2.course_id and c2.id=#{Project.table_name}.id and m2.user_id= User.current.id)
|
||||
end
|
||||
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where("( (#{Project.table_name}.updated_on=? and #{Project.table_name}.id < ?) or #{Project.table_name}.updated_on<?)",params[:lasttime],params[:lastid],params[:lasttime])
|
||||
end
|
||||
@list = query.order("#{Project.table_name}.updated_on desc,#{Project.table_name}.id desc").limit(8).all
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
|
||||
def user_course_activities
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
lastid = params[:lastid];
|
||||
end
|
||||
|
||||
user_ids = []
|
||||
if @user == User.current
|
||||
watcher = User.watched_by(@user)
|
||||
watcher.push(User.current)
|
||||
user_ids = watcher.map{|x| x.id}
|
||||
else
|
||||
user_ids << @user.id
|
||||
end
|
||||
|
||||
query = Activity.joins("join courses c on c.id=#{Activity.table_name}.activity_container_id and #{Activity.table_name}.activity_container_type='Course'")
|
||||
query = query.where("#{Activity.table_name}.user_id in (?)", user_ids)
|
||||
if User.current != @user #看别人
|
||||
if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师
|
||||
query = query.joins("join members m on c.id=m.course_id and m.user_id = #{@user.id}")
|
||||
query = query.joins("join member_roles r on m.id = r.member_id")
|
||||
query = query.where("r.role_id in(3,7,9)")
|
||||
end
|
||||
query = query.where("c.is_public=1")
|
||||
end
|
||||
if(lastid != nil)
|
||||
query = query.where("#{Activity.table_name}.id < ?",lastid)
|
||||
end
|
||||
query = query.order("#{Activity.table_name}.id desc")
|
||||
@list = query_activities(query)
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
|
||||
def user_project_activities
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
lastid = params[:lastid];
|
||||
end
|
||||
|
||||
user_ids = []
|
||||
if @user == User.current
|
||||
watcher = User.watched_by(@user)
|
||||
watcher.push(User.current)
|
||||
user_ids = watcher.map{|x| x.id}
|
||||
else
|
||||
user_ids << @user.id
|
||||
end
|
||||
|
||||
query = Activity.joins("join projects c on c.id=#{Activity.table_name}.activity_container_id and #{Activity.table_name}.activity_container_type='Project'")
|
||||
query = query.where(user_id: user_ids)
|
||||
if User.current != @user #看别人
|
||||
query = query.where("c.is_public=1")
|
||||
end
|
||||
if(lastid != nil)
|
||||
query = query.where("#{Activity.table_name}.id < ?",lastid)
|
||||
end
|
||||
query = query.order("#{Activity.table_name}.id desc")
|
||||
@list = query_activities(query)
|
||||
|
||||
render :action=>'user_course_activities',:layout=>nil
|
||||
end
|
||||
|
||||
def user_feedback4show
|
||||
query = @user.journals_for_messages
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where("#{JournalsForMessage.table_name}.id < ?",params[:lastid])
|
||||
end
|
||||
logger.info('xxoo')
|
||||
@list = query.order("#{JournalsForMessage.table_name}.id desc").limit(3).all
|
||||
logger.info('aavv')
|
||||
render :layout=>nil,:locals => {:feed_list=>@list}
|
||||
end
|
||||
|
||||
def show
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
def show_old
|
||||
pre_count = 10 #limit
|
||||
# Time 2015-02-04 11:46:34
|
||||
# Author lizanle
|
||||
|
|
@ -425,9 +553,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
when "2"
|
||||
message = []
|
||||
if @user == User.current
|
||||
if @user == User.current
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
end
|
||||
@activity_count = message.size
|
||||
@info_pages = Paginator.new @activity_count, pre_count, params['page']
|
||||
|
|
@ -458,7 +586,7 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids = []
|
||||
ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id}
|
||||
|
||||
|
|
@ -477,7 +605,7 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id}
|
||||
|
||||
#News
|
||||
|
|
@ -486,16 +614,16 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id}
|
||||
|
||||
project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
|
||||
c_ids = []
|
||||
Course.where(id: project_ids).each do |x|
|
||||
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
|
||||
end
|
||||
end
|
||||
ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id}
|
||||
|
||||
|
||||
#Message
|
||||
act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id}
|
||||
board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id}
|
||||
|
|
@ -503,14 +631,14 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id}
|
||||
|
||||
|
||||
project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id}
|
||||
c_ids = []
|
||||
Course.where(id: project_ids).each do |x|
|
||||
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
|
||||
end
|
||||
end
|
||||
ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id}
|
||||
|
||||
logger.debug "filter ids #{ids}"
|
||||
|
|
@ -528,33 +656,33 @@ class UsersController < ApplicationController
|
|||
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
|
||||
# }
|
||||
#
|
||||
|
||||
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
|
||||
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
|
||||
@state = 0
|
||||
end
|
||||
|
||||
|
||||
if params[:user].present?
|
||||
|
||||
|
||||
user_temp = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{params[:user]}%' or lastname like '%#{params[:user]}%'")
|
||||
|
||||
|
||||
if user_temp.size > 1
|
||||
activity = Activity.where('user_id in (?)', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
activity = Activity.where('user_id in (?)', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
elsif user_temp.size == 1
|
||||
activity = Activity.where('user_id = ?', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
activity = Activity.where('user_id = ?', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
else
|
||||
activity = Activity.where("1 = 0")
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@activity_count = activity.count
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
@offset ||= @activity_pages.offset
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
@state = 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
#Modified by nie
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
|
|
@ -576,17 +704,17 @@ class UsersController < ApplicationController
|
|||
def info
|
||||
|
||||
message = []
|
||||
if @user == User.current
|
||||
if @user == User.current
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@info_count = message.size
|
||||
@info_pages = Paginator.new @info_count, @limit, params['page']
|
||||
@offset ||= @info_pages.offset
|
||||
|
||||
|
||||
messages = message.sort {|x,y| y.created_on <=> x.created_on }
|
||||
|
||||
|
||||
@message = messages[@offset, @limit]
|
||||
|
||||
unless User.current.admin?
|
||||
|
|
@ -602,7 +730,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
#### end
|
||||
|
||||
|
||||
|
||||
def new
|
||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||
|
|
@ -660,7 +788,7 @@ class UsersController < ApplicationController
|
|||
@auth_sources = AuthSource.all
|
||||
@membership ||= Member.new
|
||||
end
|
||||
|
||||
|
||||
def watch_projects
|
||||
@watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', @user.id)
|
||||
@state = 1
|
||||
|
|
@ -830,42 +958,66 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
###add by huang
|
||||
def user_watchlist
|
||||
def user_watchlist
|
||||
limit = 10;
|
||||
query = User.watched_by(@user.id);
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
|
||||
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
||||
end
|
||||
###add by huang
|
||||
def user_fanslist
|
||||
|
||||
def user_fanslist
|
||||
limit = 10;
|
||||
query = @user.watcher_users;
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@action = 'fans'
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
def user_visitorlist
|
||||
limit = 10;
|
||||
#query = @user.watcher_users;
|
||||
query = User.joins("join visitors v on #{User.table_name}.id=v.user_id")
|
||||
query = query.where("v.master_id=?",@user.id)
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("v.updated_on desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@action = 'visitor'
|
||||
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
||||
end
|
||||
|
||||
#william
|
||||
def update_extensions(user_extensions)
|
||||
user_extensions = params[:user_extensions]
|
||||
unless user_extensions.nil?
|
||||
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
|
||||
|
||||
|
||||
# user_extensions.
|
||||
end
|
||||
end
|
||||
|
||||
# added by bai
|
||||
def topic_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def project_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def activity_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def influence_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def score_index
|
||||
|
||||
|
||||
end
|
||||
# end
|
||||
def topic_new_score_index
|
||||
|
|
@ -911,7 +1063,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# 必填自己的工作单位,其实就是学校
|
||||
def auth_user_extension
|
||||
if @user == User.current && @user.user_extensions.nil?
|
||||
if @user == User.current && @user.user_extensions.nil?
|
||||
flash[:error] = l(:error_complete_occupation)
|
||||
redirect_to my_account_url
|
||||
end
|
||||
|
|
@ -939,4 +1091,20 @@ class UsersController < ApplicationController
|
|||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
def recorded_visitor
|
||||
if(User.current.logged? && User.current != @user)
|
||||
#impl = Visitor.where('user_id=? and master_id=?',User.current.id,@user.id).find;
|
||||
# impl = Visitor.find_by_sql('user_id=? and master_id=?',[User.current.id,@user.id]);
|
||||
impl = Visitor.find_by_user_id_and_master_id(User.current.id,@user.id);
|
||||
if(impl.nil?)
|
||||
impl = Visitor.new
|
||||
impl.user_id = User.current.id
|
||||
impl.master_id = @user.id
|
||||
else
|
||||
impl.updated_on = Time.now
|
||||
end
|
||||
impl.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,12 +16,15 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
class WatchersController < ApplicationController
|
||||
before_filter :require_login#, :find_watchables, :only => [:watch, :unwatch]
|
||||
|
||||
helper :users
|
||||
|
||||
def watch
|
||||
s = WatchesService.new
|
||||
watchables = s.watch params.merge(:current_user_id => User.current.id)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables} }
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add'} }
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == "404"
|
||||
|
|
@ -37,7 +40,7 @@ class WatchersController < ApplicationController
|
|||
watchables = s.unwatch params.merge(:current_user_id => User.current.id)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables} }
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete'} }
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == "404"
|
||||
|
|
|
|||
|
|
@ -100,44 +100,6 @@ class WelcomeController < ApplicationController
|
|||
@course_page = FirstPage.find_by_page_type('course')
|
||||
@school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
|
||||
@logoLink ||= logolink()
|
||||
|
||||
##3-8月份为查找春季课程,9-2月份为查找秋季课程
|
||||
#month_now = Time.now.strftime("%m").to_i
|
||||
#year_now = Time.new.strftime("%Y").to_i
|
||||
#(month_now >= 3 && month_now < 9) ? course_term = l(:label_spring) : course_term = l(:label_autumn)
|
||||
##year_now -= 1 if year_now < 3
|
||||
#@school_id.nil? ? @cur_school_course = [] : @cur_school_course = find_miracle_course(10,7,@school_id, year_now, course_term)
|
||||
##未登录或者当前学校未开设课程
|
||||
#if @cur_school_course.empty?
|
||||
# @has_course = false
|
||||
# User.current.logged? ? course_count = 9 : course_count = 10
|
||||
# @cur_school_course += find_all_new_hot_course(course_count, @school_id, year_now, course_term)
|
||||
# while @cur_school_course.count < 9 do
|
||||
# if course_term == l(:label_spring)
|
||||
# course_term = l(:label_autumn)
|
||||
# year_now -= 1
|
||||
# else
|
||||
# course_term = l(:label_spring)
|
||||
# end
|
||||
# @cur_school_course += find_all_new_hot_course((10-@cur_school_course.count), nil, year_now, course_term)
|
||||
# end
|
||||
#else
|
||||
# if @cur_school_course.count < 9
|
||||
# @has_course = false
|
||||
# @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, @school_id, year_now, course_term)
|
||||
# if @cur_school_course.count < 9
|
||||
# if course_term == l(:label_spring)
|
||||
# course_term = l(:label_autumn)
|
||||
# year_now -= 1
|
||||
# else
|
||||
# course_term = l(:label_spring)
|
||||
# end
|
||||
# @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, nil, year_now, course_term)
|
||||
# end
|
||||
# else
|
||||
# @has_course = true
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
def logolink()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class WordsController < ApplicationController
|
|||
include ApplicationHelper
|
||||
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
|
||||
def create
|
||||
if params[:new_form][:user_message].size>0
|
||||
if params[:new_form][:user_message].size>0 && User.current.logged?
|
||||
unless params[:user_id].nil?
|
||||
if params[:reference_content]
|
||||
message = params[:new_form][:user_message] + "\n" + params[:reference_content]
|
||||
|
|
@ -13,26 +13,18 @@ class WordsController < ApplicationController
|
|||
end
|
||||
refer_user_id = params[:new_form][:reference_user_id].to_i
|
||||
|
||||
@user.add_jour(User.current, message, refer_user_id)
|
||||
list = @user.add_jour(User.current, message, refer_user_id)
|
||||
unless refer_user_id == 0 || refer_user_id == User.current.id
|
||||
User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
|
||||
list = User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
|
||||
end
|
||||
@user.count_new_jour
|
||||
# if a_message.size > 5
|
||||
# @message = a_message[-5, 5]
|
||||
# else
|
||||
# @message = a_message
|
||||
# end
|
||||
# @message_count = a_message.count
|
||||
@jour = list.last
|
||||
end
|
||||
end
|
||||
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse
|
||||
@jour = paginateHelper @jours,10
|
||||
jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jour = paginateHelper jours,10
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -88,10 +80,10 @@ class WordsController < ApplicationController
|
|||
elsif @journal_destroyed.jour_type == "Principal"
|
||||
@user = User.find(@journal_destroyed.jour_id)
|
||||
@jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
@is_user = true
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -204,7 +196,15 @@ class WordsController < ApplicationController
|
|||
flash[:error] = feedback.errors.full_messages[0]
|
||||
redirect_to project_feedback_url(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
#给用户留言
|
||||
def leave_user_message
|
||||
@user = User.find(params[:id])
|
||||
if params[:new_form][:user_message].size>0 && User.current.logged? && @user
|
||||
@user.add_jour(User.current, params[:new_form][:user_message])
|
||||
end
|
||||
redirect_to feedback_path(@user)
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
|
|
|
|||
|
|
@ -42,4 +42,33 @@ module ActivitiesHelper
|
|||
end
|
||||
sorted_events
|
||||
end
|
||||
|
||||
def get_container_type(activity)
|
||||
if activity.act.nil?
|
||||
return ['Unknow',0]
|
||||
end
|
||||
#问卷
|
||||
if activity.act_type == 'Poll'
|
||||
return ['Course',activity.act.polls_group_id]
|
||||
end
|
||||
#注册
|
||||
if activity.act_type == 'Principal'
|
||||
return ['Principal',activity.act.id]
|
||||
end
|
||||
#留言
|
||||
if activity.act_type == 'JournalsForMessage'
|
||||
return [activity.act.jour_type,activity.act.jour_id,activity.act.user_id]
|
||||
end
|
||||
|
||||
# HomeworkCommon Issue Journal Message News
|
||||
if activity.act.respond_to?('course') && activity.act.course
|
||||
return ['Course',activity.act.course.id]
|
||||
end
|
||||
if activity.act.respond_to?('project') && activity.act.project
|
||||
return ['Project',activity.act.project.id]
|
||||
end
|
||||
|
||||
# Contest Contestnotification
|
||||
return ['Unknow',0]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# encoding: utf-8
|
||||
module ApiHelper
|
||||
ONE_MINUTE = 60 * 1000
|
||||
ONE_HOUR = 60 * ONE_MINUTE
|
||||
ONE_DAY = 24 * ONE_HOUR
|
||||
ONE_MONTH = 30 * ONE_DAY
|
||||
|
||||
ONE_YEAR = 12 * ONE_MONTH
|
||||
#获取用户的工作单位
|
||||
def get_user_work_unit user
|
||||
work_unit = ""
|
||||
|
|
@ -66,7 +72,7 @@ module ApiHelper
|
|||
(user.language.nil? || user.language == "") ? 'zh':user.language
|
||||
end
|
||||
|
||||
# 获取课程作业的状态
|
||||
# 学生获取课程作业的状态
|
||||
def get_homework_status homework
|
||||
homework_status = ""
|
||||
if !homework.nil?
|
||||
|
|
@ -75,9 +81,9 @@ module ApiHelper
|
|||
when 1
|
||||
homework_status = show_homework_deadline homework
|
||||
when 2
|
||||
homework_status = "正在匿评中"
|
||||
homework_status = "正在匿评"
|
||||
when 3
|
||||
homework_status = "匿评已结束"
|
||||
homework_status = "匿评结束"
|
||||
end
|
||||
elsif homework.homework_type == 0
|
||||
homework_status = "未启用匿评"
|
||||
|
|
@ -93,7 +99,7 @@ module ApiHelper
|
|||
def homework_status_desc homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
link = "截止日期之前不可启动匿评"
|
||||
link = show_homework_deadline homework
|
||||
elsif homework.student_works.count >= 2 #作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
|
|
@ -104,10 +110,10 @@ module ApiHelper
|
|||
link = " 匿评结束"
|
||||
end
|
||||
else
|
||||
link = "提交作业数大于2才可启动匿评"
|
||||
link = "提交作业数过少"
|
||||
end
|
||||
else
|
||||
link = "未开启匿评作业不可启动匿评"
|
||||
link = "未开启匿评作业"
|
||||
end
|
||||
link
|
||||
end
|
||||
|
|
@ -129,9 +135,71 @@ module ApiHelper
|
|||
def show_homework_deadline homework
|
||||
day = 0
|
||||
if (day = (Date.parse(homework.end_time.to_s) - Date.parse(Time.now.to_s)).to_i) > 0
|
||||
"距作业截止还有" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天"
|
||||
"距作业截止还有" << day.to_s << "天"
|
||||
else
|
||||
"已截止,但可补交"
|
||||
end
|
||||
end
|
||||
|
||||
#获取作业中学生的匿评比率
|
||||
# 匿评比率 = 学生总共评价的作业的作业份数 / 作业份数 * 分配数 * 100%
|
||||
# 教辅匿评比率 = 教辅已经评价的作业份数 / 总的作业份数 * 100%
|
||||
def get_evaluation_part homework,role
|
||||
homework_eva_completed_task_num = 0
|
||||
homework_eva_task_num = 0
|
||||
#匿评作业 # 且匿评状态不是还没有开启匿评
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1
|
||||
# 总共需要评价的任务数
|
||||
homework_eva_task_num = homework.homework_detail_manual.evaluation_num * homework.student_works.count
|
||||
unless homework_eva_task_num == 0 #总任务数不为0 的情况下
|
||||
#获取已经评价了多少的份作业 student_work_score里记录了评价情况,每条记录有提交作业的id
|
||||
#先求出提交作业的id集合
|
||||
work_ids = "(" + homework.student_works.map(&:id).join(",") + ")"
|
||||
#只要 student_work_score 中的 student_work_id在work_ids集合中,那么久说明这个任务被完成了
|
||||
|
||||
sql = "select count(1) from student_works_scores where reviewer_role = #{role} and student_work_id in #{work_ids} "
|
||||
homework_eva_completed_task_num = ActiveRecord::Base.connection().select_value(sql)
|
||||
end
|
||||
end
|
||||
if homework_eva_task_num == 0
|
||||
0
|
||||
else
|
||||
( homework_eva_completed_task_num / homework_eva_task_num.to_f * 100 ) .round(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# 获取当前时间
|
||||
def time_from_now time
|
||||
lastUpdateTime = time.to_i*1000
|
||||
|
||||
currentTime = Time.now.to_i*1000
|
||||
timePassed = currentTime - lastUpdateTime;
|
||||
timeIntoFormat = 0
|
||||
updateAtValue = ""
|
||||
if timePassed < 0
|
||||
updateAtValue = "时间有问题"
|
||||
elsif timePassed < ONE_MINUTE
|
||||
updateAtValue = "一分钟前"
|
||||
elsif timePassed < ONE_HOUR
|
||||
timeIntoFormat = timePassed / ONE_MINUTE
|
||||
updateAtValue = timeIntoFormat.to_s + "分钟前"
|
||||
elsif (timePassed < ONE_DAY)
|
||||
timeIntoFormat = timePassed / ONE_HOUR
|
||||
updateAtValue = timeIntoFormat.to_s + "小时前"
|
||||
elsif (timePassed < ONE_MONTH)
|
||||
timeIntoFormat = timePassed / ONE_DAY
|
||||
updateAtValue = timeIntoFormat.to_s + "天前"
|
||||
elsif (timePassed < ONE_YEAR)
|
||||
timeIntoFormat = timePassed / ONE_MONTH
|
||||
updateAtValue = timeIntoFormat.to_s + "个月前"
|
||||
else
|
||||
timeIntoFormat = timePassed / ONE_YEAR
|
||||
updateAtValue = timeIntoFormat.to_s + "年前"
|
||||
end
|
||||
updateAtValue
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
@ -1812,7 +1812,7 @@ module ApplicationHelper
|
|||
#获取用户未过期的课程
|
||||
def get_user_course user
|
||||
courses_doing = []
|
||||
user.courses.each do |course|
|
||||
user.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course|
|
||||
if !course_endTime_timeout?(course)
|
||||
courses_doing.push course
|
||||
end
|
||||
|
|
@ -1824,7 +1824,9 @@ module ApplicationHelper
|
|||
def attachment_candown attachment
|
||||
candown = false
|
||||
if attachment.container
|
||||
if attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
|
||||
if attachment.container.class.to_s=="PhoneAppVersion"
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
|
||||
project = attachment.container.project
|
||||
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif attachment.container.is_a?(Project)
|
||||
|
|
@ -1850,6 +1852,7 @@ module ApplicationHelper
|
|||
candown = true
|
||||
elsif attachment.container.class.to_s=="StudentWork"
|
||||
candown = true
|
||||
|
||||
elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses
|
||||
course = attachment.container.courses.first
|
||||
candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1)
|
||||
|
|
@ -2292,6 +2295,8 @@ module ApplicationHelper
|
|||
else
|
||||
link = "<span class='fr mr10 pr_join_span ' title='学生提交作业数大于2时才可以启动匿评'>启动匿评</span>".html_safe
|
||||
end
|
||||
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业
|
||||
link = "<span class='fr mr10 pr_join_span ' title='编程作业'>编程作业</span>".html_safe
|
||||
else
|
||||
link = "<span class='fr mr10 pr_join_span ' title='未开启匿评作业不可以启动匿评'>启动匿评</span>".html_safe
|
||||
end
|
||||
|
|
@ -2305,6 +2310,8 @@ module ApplicationHelper
|
|||
else
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
|
||||
"<span class='fr mr10 pr_join_span '>#{l(:label_edit_homework)}</span>".html_safe
|
||||
elsif homework.homework_type == 2 #编程作业不能修改作品
|
||||
"<span class='fr mr10 pr_join_span ' title='编程作业不可修改作品'>作品已交</span>".html_safe
|
||||
else
|
||||
link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit'
|
||||
end
|
||||
|
|
@ -2324,7 +2331,7 @@ module ApplicationHelper
|
|||
elsif homework.homework_type == 0
|
||||
"<span class='fr mr10 pr_join_span '>未启用匿评</span>".html_safe
|
||||
elsif homework.homework_type == 2
|
||||
"<span class='fr mr10 pr_join_span '>编程作业</span>".html_safe
|
||||
"<span class='fr mr10 pr_join_span '> 编程作业 </span>".html_safe
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -2339,4 +2346,130 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
#将文本内的/n转换为<br>
|
||||
def text_format text
|
||||
text.gsub("&","&").gsub("<","<").gsub(">",">").gsub("\n","<br/>").html_safe
|
||||
end
|
||||
|
||||
#评分规则显示
|
||||
def scoring_rules late_penalty,homework_id,is_teacher,absence_penalty=nil
|
||||
if absence_penalty
|
||||
if late_penalty.to_i == 0 && absence_penalty.to_i == 0
|
||||
notice = "尚未设置评分规则"
|
||||
if is_teacher
|
||||
notice += ",请 " + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
|
||||
end
|
||||
elsif late_penalty.to_i != 0 && absence_penalty.to_i == 0
|
||||
notice = "迟交扣#{late_penalty}分,缺评扣分未设置"
|
||||
elsif late_penalty.to_i == 0 && absence_penalty.to_i != 0
|
||||
notice = "迟交扣分未设置,缺评一个作品扣#{absence_penalty}分"
|
||||
elsif late_penalty.to_i != 0 && absence_penalty.to_i != 0
|
||||
notice = "迟交扣#{late_penalty}分,缺评一个作品扣#{absence_penalty}分"
|
||||
end
|
||||
else
|
||||
if late_penalty.to_i == 0
|
||||
notice = "尚未设置评分规则"
|
||||
if is_teacher
|
||||
notice += ",请 " + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
|
||||
end
|
||||
else
|
||||
notice = "迟交扣#{late_penalty}分"
|
||||
end
|
||||
end
|
||||
notice.html_safe
|
||||
end
|
||||
|
||||
#老师C语言的标准代码
|
||||
def c_stantard_code_teacher
|
||||
"// 老师您好!这是一个C语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <stdio.h> //引用必须头文件
|
||||
int main(int argc, char** argv) {
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
|
||||
printf(\"%d\",a+b); //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
|
||||
#老师C++语言的标准代码
|
||||
def c_stantard_code_teacher_
|
||||
"// 老师您好!这是一个C++语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <iostream> //引用必须头文件
|
||||
#include <cstdlib>
|
||||
using namespace std;
|
||||
int main(int argc, char** argv){
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
cout<<a+b; //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
|
||||
#学生C语言的标准代码
|
||||
def c_stantard_code_student
|
||||
"// 同学好!这是一个C语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <stdio.h> //引用必须头文件
|
||||
int main(int argc, char** argv) {
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
|
||||
printf(\"%d\",a+b); //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
|
||||
#学生C++语言的标准代码
|
||||
def c_stantard_code_student_
|
||||
"// 同学好!这是一个C++语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <iostream> //引用必须头文件
|
||||
#include <cstdlib>
|
||||
using namespace std;
|
||||
int main(int argc, char** argv){
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
cout<<a+b; //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -520,10 +520,14 @@ module CoursesHelper
|
|||
option1 << l(:label_spring)
|
||||
option1 << l(:label_spring)
|
||||
option2 = []
|
||||
option2 << l(:label_autumn)
|
||||
option2 << l(:label_autumn)
|
||||
option2 << l(:label_summer)
|
||||
option2 << l(:label_summer)
|
||||
option3 = []
|
||||
option3 << l(:label_autumn)
|
||||
option3 << l(:label_autumn)
|
||||
type << option1
|
||||
type << option2
|
||||
type << option3
|
||||
type
|
||||
end
|
||||
|
||||
|
|
@ -546,8 +550,9 @@ module CoursesHelper
|
|||
end
|
||||
if cur_course_term == "秋季学期" && course.time == (year_now + 1) && course.term == "春季学期"
|
||||
is_next_term = true
|
||||
elsif cur_course_term == "春季学期" && course.time == year_now && course.term == "秋季学期"
|
||||
elsif cur_course_term == "春季学期" && course.time == year_now && course.term == "夏季学期"
|
||||
is_next_term = true
|
||||
elsif cur_course_term == "夏季学期" && course.time == year_now && course.term == "秋季学期"
|
||||
end
|
||||
is_current_term || is_next_term
|
||||
end
|
||||
|
|
@ -671,4 +676,61 @@ module CoursesHelper
|
|||
end
|
||||
result
|
||||
end
|
||||
|
||||
#生成课程相关动态的链接
|
||||
def course_activity_link activity
|
||||
# activity = CourseActivity.first
|
||||
title = ""
|
||||
url = ""
|
||||
if activity.course_act
|
||||
case activity.course_act_type
|
||||
when "Course"
|
||||
title = activity.course_act.name
|
||||
url = course_path activity.course
|
||||
when "HomeworkCommon"
|
||||
title = "作业 " + activity.course_act.name
|
||||
url = student_work_index_path(:homework => activity.course_act.id)
|
||||
when "News"
|
||||
title = "通知公告 " + activity.course_act.title
|
||||
url = course_news_index_path(activity.course)
|
||||
when "Attachment"
|
||||
title = "课件 " + activity.course_act.filename
|
||||
url = course_files_path(activity.course)
|
||||
when "Message"
|
||||
title = "课程讨论区 " + activity.course_act.subject
|
||||
url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id)
|
||||
when "JournalsForMessage"
|
||||
title = "留言 " + activity.course_act.notes
|
||||
url = course_feedback_path(activity.course)
|
||||
when "Poll"
|
||||
title = "问卷 " + activity.course_act.polls_name
|
||||
url = poll_path(activity.course_act_id)
|
||||
end
|
||||
end
|
||||
link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
|
||||
end
|
||||
|
||||
#课程动态的描述
|
||||
def course_activity_desc activity
|
||||
desc = ""
|
||||
if activity.course_act
|
||||
case activity.course_act_type
|
||||
when "Course"
|
||||
desc = ""
|
||||
when "HomeworkCommon"
|
||||
desc = activity.course_act.description
|
||||
when "News"
|
||||
desc = activity.course_act.description
|
||||
when "Attachment"
|
||||
desc = ""
|
||||
when "Message"
|
||||
desc = activity.course_act.content
|
||||
when "JournalsForMessage"
|
||||
desc = ""
|
||||
when "Poll"
|
||||
desc = activity.course_act.polls_description
|
||||
end
|
||||
end
|
||||
desc.html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,149 +1,149 @@
|
|||
module HomeworkAttachHelper
|
||||
#判断是否具有删除的权限
|
||||
def attach_delete(project)
|
||||
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
#作业添加、编辑界面的tab页
|
||||
def homework_settings_tabs f
|
||||
@f = f
|
||||
tabs = [{:name => 'info', :partial => 'homework_attach/edit_homework', :label => :label_information_plural},
|
||||
{:name => 'members', :partial => 'homework_attach/homework_member', :label => :label_member_plural}
|
||||
]
|
||||
end
|
||||
|
||||
#作业可选成员列表分页
|
||||
def render_new_members_for_homework members
|
||||
#scope = Principal.active.sorted.not_member_of(project).like(params[:q])
|
||||
#scope = project.members
|
||||
#principals = paginateHelper members,10
|
||||
#principals = members
|
||||
#principal_count = members.count
|
||||
#limit = 10
|
||||
#principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young
|
||||
#offset ||= principal_pages.offset
|
||||
#principals = members[offset, limit]
|
||||
users = members.map(&:user)
|
||||
s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', users), :id => 'principals')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
|
||||
link_to text, get_homework_member_list_homework_attach_index_path( parameters.merge(:q => params[:q], bid_id: params[:id]||@homework)), :remote => true }
|
||||
return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||
end
|
||||
|
||||
#扩展的checkbox生成
|
||||
def member_check_box_tags_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |member|
|
||||
s << "<label>#{ check_box_tag name, member.id, false, :id => nil } #{h member.name }</label><br/>"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
def paginateHelper obj, pre_size=20
|
||||
@obj_count = obj.count
|
||||
@obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page']
|
||||
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
||||
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
|
||||
elsif obj.kind_of? Array
|
||||
obj[@obj_pages.offset, @obj_pages.per_page]
|
||||
else
|
||||
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
|
||||
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
end
|
||||
end
|
||||
|
||||
def user_projects_option
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
memberships = User.current.memberships.all(:conditions => cond)
|
||||
projects = memberships.map(&:project)
|
||||
not_have_project = []
|
||||
not_have_project << Setting.please_chose
|
||||
not_have_project << 0
|
||||
type = []
|
||||
type << not_have_project
|
||||
projects.each do |project|
|
||||
if project != nil
|
||||
option = []
|
||||
option << project.name
|
||||
option << project.id
|
||||
type << option
|
||||
end
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
#判断指定用户是不是已经赞过该作业
|
||||
def is_praise_homework user_id, obj_id
|
||||
PraiseTread.where("user_id = #{user_id} AND praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").empty?
|
||||
end
|
||||
|
||||
#获取赞的总数
|
||||
def praise_homework_count obj_id
|
||||
PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").count
|
||||
end
|
||||
|
||||
#获取用户对作业的评分
|
||||
def get_homework_score user, homework
|
||||
temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id} AND rater_id = #{user.id}").first
|
||||
@m_score = temp.nil? ? 0:temp.stars.to_i
|
||||
end
|
||||
|
||||
#获取评分对应的评论
|
||||
def get_homework_review homework,is_teacher,user
|
||||
homework.journals_for_messages.where("is_comprehensive_evaluation = #{is_teacher ? 1 : 2} and user_id = #{user.id}").order("created_on DESC").first
|
||||
end
|
||||
|
||||
def convert_array array
|
||||
ary = "("
|
||||
if array.nil? || array.count == 0
|
||||
return "()"
|
||||
end
|
||||
array.length.times do |i|
|
||||
if i == array.length - 1
|
||||
ary += array[i].id.to_s + ")"
|
||||
else
|
||||
if !(array[i].nil? || array[i].id.nil? || array[i].id.to_s == "")
|
||||
ary += array[i].id.to_s + ","
|
||||
end
|
||||
end
|
||||
end
|
||||
#array.each do |member|
|
||||
# if member == array.last
|
||||
# ary += member.id.to_s + ")"
|
||||
# else
|
||||
# ary += member.id.to_s + ","
|
||||
# end
|
||||
#end
|
||||
ary
|
||||
end
|
||||
|
||||
def get_student_batch_homework_list bid,user
|
||||
student_batch_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,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.current.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} 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 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
|
||||
# #判断是否具有删除的权限
|
||||
# def attach_delete(project)
|
||||
# if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
||||
# true
|
||||
# else
|
||||
# false
|
||||
# end
|
||||
# end
|
||||
# #作业添加、编辑界面的tab页
|
||||
# def homework_settings_tabs f
|
||||
# @f = f
|
||||
# tabs = [{:name => 'info', :partial => 'homework_attach/edit_homework', :label => :label_information_plural},
|
||||
# {:name => 'members', :partial => 'homework_attach/homework_member', :label => :label_member_plural}
|
||||
# ]
|
||||
# end
|
||||
#
|
||||
# #作业可选成员列表分页
|
||||
# def render_new_members_for_homework members
|
||||
# #scope = Principal.active.sorted.not_member_of(project).like(params[:q])
|
||||
# #scope = project.members
|
||||
# #principals = paginateHelper members,10
|
||||
# #principals = members
|
||||
# #principal_count = members.count
|
||||
# #limit = 10
|
||||
# #principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young
|
||||
# #offset ||= principal_pages.offset
|
||||
# #principals = members[offset, limit]
|
||||
# users = members.map(&:user)
|
||||
# s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', users), :id => 'principals')
|
||||
# links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
|
||||
# link_to text, get_homework_member_list_homework_attach_index_path( parameters.merge(:q => params[:q], bid_id: params[:id]||@homework)), :remote => true }
|
||||
# return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||
# end
|
||||
#
|
||||
# #扩展的checkbox生成
|
||||
# def member_check_box_tags_ex(name, principals)
|
||||
# s = ''
|
||||
# principals.each do |member|
|
||||
# s << "<label>#{ check_box_tag name, member.id, false, :id => nil } #{h member.name }</label><br/>"
|
||||
# end
|
||||
# s.html_safe
|
||||
# end
|
||||
#
|
||||
# def paginateHelper obj, pre_size=20
|
||||
# @obj_count = obj.count
|
||||
# @obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page']
|
||||
# if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
||||
# obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
|
||||
# elsif obj.kind_of? Array
|
||||
# obj[@obj_pages.offset, @obj_pages.per_page]
|
||||
# else
|
||||
# logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
|
||||
# raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def user_projects_option
|
||||
# cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
# memberships = User.current.memberships.all(:conditions => cond)
|
||||
# projects = memberships.map(&:project)
|
||||
# not_have_project = []
|
||||
# not_have_project << Setting.please_chose
|
||||
# not_have_project << 0
|
||||
# type = []
|
||||
# type << not_have_project
|
||||
# projects.each do |project|
|
||||
# if project != nil
|
||||
# option = []
|
||||
# option << project.name
|
||||
# option << project.id
|
||||
# type << option
|
||||
# end
|
||||
# end
|
||||
# type
|
||||
# end
|
||||
#
|
||||
# #判断指定用户是不是已经赞过该作业
|
||||
# def is_praise_homework user_id, obj_id
|
||||
# PraiseTread.where("user_id = #{user_id} AND praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").empty?
|
||||
# end
|
||||
#
|
||||
# #获取赞的总数
|
||||
# def praise_homework_count obj_id
|
||||
# PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").count
|
||||
# end
|
||||
#
|
||||
# #获取用户对作业的评分
|
||||
# def get_homework_score user, homework
|
||||
# temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id} AND rater_id = #{user.id}").first
|
||||
# @m_score = temp.nil? ? 0:temp.stars.to_i
|
||||
# end
|
||||
#
|
||||
# #获取评分对应的评论
|
||||
# def get_homework_review homework,is_teacher,user
|
||||
# homework.journals_for_messages.where("is_comprehensive_evaluation = #{is_teacher ? 1 : 2} and user_id = #{user.id}").order("created_on DESC").first
|
||||
# end
|
||||
#
|
||||
# def convert_array array
|
||||
# ary = "("
|
||||
# if array.nil? || array.count == 0
|
||||
# return "()"
|
||||
# end
|
||||
# array.length.times do |i|
|
||||
# if i == array.length - 1
|
||||
# ary += array[i].id.to_s + ")"
|
||||
# else
|
||||
# if !(array[i].nil? || array[i].id.nil? || array[i].id.to_s == "")
|
||||
# ary += array[i].id.to_s + ","
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# #array.each do |member|
|
||||
# # if member == array.last
|
||||
# # ary += member.id.to_s + ")"
|
||||
# # else
|
||||
# # ary += member.id.to_s + ","
|
||||
# # end
|
||||
# #end
|
||||
# ary
|
||||
# end
|
||||
#
|
||||
# def get_student_batch_homework_list bid,user
|
||||
# student_batch_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,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.current.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} 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 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
|
||||
|
|
@ -3,7 +3,8 @@ module HomeworkCommonHelper
|
|||
#迟交扣分下拉框
|
||||
def late_penalty_option
|
||||
type = []
|
||||
for i in (0..5)
|
||||
type << l(:lable_unset)
|
||||
for i in (1..5)
|
||||
option = []
|
||||
option << i
|
||||
option << i
|
||||
|
|
@ -26,10 +27,24 @@ module HomeworkCommonHelper
|
|||
type
|
||||
end
|
||||
|
||||
def programing_languages_options
|
||||
type = []
|
||||
option = []
|
||||
option << "C"
|
||||
option << 1
|
||||
type << option
|
||||
option_1 = []
|
||||
option_1 << "C++"
|
||||
option_1 << 2
|
||||
type << option_1
|
||||
type
|
||||
end
|
||||
|
||||
#缺评扣分
|
||||
def absence_penalty_option
|
||||
type = []
|
||||
i = 0
|
||||
i = 1
|
||||
type << l(:lable_unset)
|
||||
while i <= 5
|
||||
option = []
|
||||
option << i
|
||||
|
|
@ -50,4 +65,32 @@ module HomeworkCommonHelper
|
|||
end
|
||||
link
|
||||
end
|
||||
|
||||
#将状态转换为错误信息
|
||||
def status_to_err_msg status
|
||||
case status.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
'输入和输出不匹配'
|
||||
when -3
|
||||
'输入和输出不匹配'
|
||||
when 1
|
||||
'运行出错'
|
||||
when 2
|
||||
'超时'
|
||||
when 3
|
||||
'内存超出'
|
||||
when 4
|
||||
'输出超出'
|
||||
when 5
|
||||
'禁用函数'
|
||||
when 6
|
||||
'其他错误'
|
||||
when 0
|
||||
'成功'
|
||||
else
|
||||
'未知错误'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -68,27 +68,47 @@ module IssuesHelper
|
|||
end
|
||||
|
||||
#获取跟踪类型及样式
|
||||
#REDO:时间紧可以优化.
|
||||
def get_issue_type(value)
|
||||
issuetype = []
|
||||
if value == "缺陷" || value == 1
|
||||
issuetype << "red_btn_cir ml10"
|
||||
issuetype << "issues fl"
|
||||
issuetype << "缺陷"
|
||||
elsif value == "功能" || value == 2
|
||||
issuetype << "blue_btn_cir ml10"
|
||||
issuetype << "功能"
|
||||
elsif value == "支持" || value == 3
|
||||
issuetype << "green_btn_cir ml10"
|
||||
issuetype << "支持"
|
||||
elsif value == "任务" || value == 4
|
||||
issuetype << "orange_btn_cir ml10"
|
||||
issuetype << "duty fl"
|
||||
issuetype << "任务"
|
||||
elsif value == "支持" || value == 3
|
||||
issuetype << "support fl"
|
||||
issuetype << "支持"
|
||||
elsif value == "功能" || value == 2
|
||||
issuetype << "function fl"
|
||||
issuetype << "功能"
|
||||
else
|
||||
issuetype << "bgreen_btn_cir ml10"
|
||||
issuetype << "weekly fl"
|
||||
issuetype << "周报"
|
||||
end
|
||||
end
|
||||
|
||||
# 获取优先级样式 value值1 2 低
|
||||
def get_issue_priority(value)
|
||||
issuetype = []
|
||||
if value == "紧急" || value == 4
|
||||
issuetype << "red_btn_cir ml10"
|
||||
issuetype << "紧急"
|
||||
elsif value == "正常" || value == 2
|
||||
issuetype << "green_btn_cir ml10"
|
||||
issuetype << "正常"
|
||||
elsif value == "高" || value == 3
|
||||
issuetype << "orange_btn_cir ml10"
|
||||
issuetype << "高"
|
||||
elsif value == "低" || value == 1
|
||||
issuetype << "bgreen_btn_cir ml10"
|
||||
issuetype << "低"
|
||||
else
|
||||
issuetype << "red_btn_cir ml10"
|
||||
issuetype << "立刻"
|
||||
end
|
||||
end
|
||||
|
||||
def principals_options_for_isuue_list(project)
|
||||
if User.current.member_of?(project)
|
||||
project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0])
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ module MembersHelper
|
|||
scope = []
|
||||
end
|
||||
principals = paginateHelper scope,10
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5')
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
|
||||
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,4 +74,13 @@ module PollHelper
|
|||
end
|
||||
end
|
||||
|
||||
#带勾选框的问卷列表
|
||||
def poll_check_box_tags(name,polls,current_poll)
|
||||
s = ''
|
||||
polls.each do |poll|
|
||||
s << "<label>#{ check_box_tag name, poll.id, false, :id => nil } #{h poll.polls_name.blank? ? l(:label_poll_new) : poll.polls_name } [#{ h Course.find(poll.polls_group_id).name}]</label><br/>"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -20,9 +20,9 @@ module PraiseTreadHelper
|
|||
# when 0
|
||||
# return @record.tread_num.nil? ? 0 : @record.tread_num
|
||||
# end
|
||||
return (@record.praise_num.to_i-@record.tread_num.to_i)
|
||||
return ((@record.praise_num.nil? ? 0 : @record.praise_num.to_i)-(@record.tread_num.nil? ? 0 : @record.tread_num.to_i))
|
||||
else
|
||||
return 0
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -236,13 +236,14 @@ module RepositoriesHelper
|
|||
# 判断项目是否有主版本库
|
||||
def judge_main_repository(pro)
|
||||
if pro.repositories.blank?
|
||||
return false
|
||||
status = false
|
||||
else
|
||||
pro.repositories.sort.each do |rep|
|
||||
rep.is_default?
|
||||
return true
|
||||
pro.repositories.each do |rep|
|
||||
status = true and break if rep.is_default?
|
||||
status = false
|
||||
end
|
||||
end
|
||||
status
|
||||
end
|
||||
# def cvs_field_tags(form, repository)
|
||||
# content_tag('p', form.text_field(
|
||||
|
|
|
|||
|
|
@ -80,4 +80,22 @@ module StudentWorkHelper
|
|||
end
|
||||
color
|
||||
end
|
||||
|
||||
#获取分班信息
|
||||
def course_group_list course
|
||||
result = []
|
||||
if course.course_groups && !course.course_groups.empty?
|
||||
base = []
|
||||
base << l(:label_chose_group)
|
||||
base << 0
|
||||
result << base
|
||||
course.course_groups.each do |group|
|
||||
option = []
|
||||
option << group.name
|
||||
option << group.id
|
||||
result << option
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
|
@ -433,7 +433,7 @@ module UserScoreHelper
|
|||
|
||||
#协同得分
|
||||
def collaboration(option_number)
|
||||
option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo
|
||||
option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo
|
||||
end
|
||||
#影响力得分
|
||||
def influence(option_number)
|
||||
|
|
@ -445,7 +445,7 @@ module UserScoreHelper
|
|||
end
|
||||
#项目贡献得分
|
||||
def active(option_number)
|
||||
option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4
|
||||
option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2
|
||||
end
|
||||
|
||||
#更新发帖数
|
||||
|
|
|
|||
|
|
@ -303,4 +303,207 @@ module UsersHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_watcher_users(obj)
|
||||
count = User.watched_by(obj.id).count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all
|
||||
return [count,list];
|
||||
end
|
||||
|
||||
def get_fans_users(obj)
|
||||
count = obj.watcher_users.count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
|
||||
return [count,list];
|
||||
end
|
||||
|
||||
def get_visitor_users(obj)
|
||||
query = Visitor.where("master_id=?",obj.id)
|
||||
count = query.count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = query.order("updated_on desc").limit(10).all
|
||||
return [count,list]
|
||||
end
|
||||
|
||||
def get_create_course_count(user)
|
||||
user.courses.visible.where("tea_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#获取加入课程数
|
||||
def get_join_course_count(user)
|
||||
user.courses.visible.count - get_create_course_count(user)
|
||||
end
|
||||
|
||||
#发布作业数
|
||||
def get_homework_commons_count(user)
|
||||
HomeworkCommon.where("user_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#资源数
|
||||
def get_projectandcourse_attachment_count(user)
|
||||
Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
|
||||
end
|
||||
|
||||
#创建项目数
|
||||
def get_create_project_count(user)
|
||||
user.projects.visible.where("projects.user_id=#{user.id}").count
|
||||
end
|
||||
|
||||
#加入项目数
|
||||
def get_join_project_count(user)
|
||||
user.projects.visible.count - get_create_project_count(user)
|
||||
end
|
||||
|
||||
#创建缺陷数
|
||||
def get_create_issue_count(user)
|
||||
Issue.where("author_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#解决缺陷数
|
||||
def get_resolve_issue_count(user)
|
||||
Issue.where("assigned_to_id = ? and status_id=3",user.id).count
|
||||
end
|
||||
|
||||
#参与匿评数
|
||||
def get_anonymous_evaluation_count(user)
|
||||
StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
|
||||
end
|
||||
|
||||
def query_activities(query)
|
||||
list = query.limit(13).all
|
||||
result = []
|
||||
for item in list
|
||||
container = get_activity_container(item)
|
||||
result << { :item=>item,:e=>container }
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def get_activity_container activity
|
||||
return activity.activity_container
|
||||
end
|
||||
|
||||
def get_activity_act_showname_htmlclear(activity)
|
||||
str = get_activity_act_showname(activity)
|
||||
str = str.gsub(/<.*>/,'')
|
||||
str = str.gsub(/\r/,'')
|
||||
str = str.gsub(/\n/,'')
|
||||
str = str.lstrip.rstrip
|
||||
if str == ''
|
||||
str = 'RE:'
|
||||
end
|
||||
return str.html_safe
|
||||
end
|
||||
|
||||
def get_activity_act_showname(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
return activity.act.name
|
||||
when "Issue"
|
||||
return activity.act.subject
|
||||
when "Journal"
|
||||
arr = details_to_strings(activity.act.details,true)
|
||||
arr << activity.act.notes
|
||||
str = ''
|
||||
arr.each { |item| str = str+item }
|
||||
return str
|
||||
when "JournalsForMessage"
|
||||
return activity.act.notes
|
||||
when "Message"
|
||||
return activity.act.subject
|
||||
when "News"
|
||||
return activity.act.title
|
||||
when "Poll"
|
||||
return activity.act.polls_name
|
||||
when "Contest"
|
||||
return ''
|
||||
when "Contestnotification"
|
||||
return ''
|
||||
when "Principal"
|
||||
return ''
|
||||
else
|
||||
return activity.act_type
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_act_createtime(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
return activity.act.created_at
|
||||
when "Poll"
|
||||
return activity.act.created_at
|
||||
else
|
||||
return activity.act.created_on
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_container_url e
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
end
|
||||
|
||||
if e.class.to_s == 'Course'
|
||||
return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course)
|
||||
end
|
||||
return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name)
|
||||
end
|
||||
|
||||
def get_activity_url(activity,e)
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
end
|
||||
|
||||
case activity.act_type
|
||||
# when "Contest"
|
||||
# when "Contestnotification"
|
||||
# when "Principal"
|
||||
when "HomeworkCommon"
|
||||
return homework_common_index_path( :course=>e.id )
|
||||
when "Issue"
|
||||
return issue_path(activity.act.id)
|
||||
when "Journal"
|
||||
return issue_path( activity.act.journalized_id )
|
||||
when "JournalsForMessage"
|
||||
return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e)
|
||||
when "Message"
|
||||
return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e)
|
||||
when "News"
|
||||
return news_path(activity.act)
|
||||
#return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e)
|
||||
when "Poll"
|
||||
return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s )
|
||||
else
|
||||
return 'javascript:;'
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_opt(activity,e)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
return '创建了作业'
|
||||
when "News"
|
||||
return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻'
|
||||
when "Issue"
|
||||
return '发表了问题'
|
||||
when "Journal"
|
||||
return '更新了问题'
|
||||
when "JournalsForMessage"
|
||||
return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈'
|
||||
#return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : ''
|
||||
when "Message"
|
||||
return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子'
|
||||
when "Poll"
|
||||
return '创建了问卷'
|
||||
else
|
||||
return '有了新动态'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -169,14 +169,14 @@ module WatchersHelper
|
|||
if joined
|
||||
link_to text, {:controller => "courses", :action => "join_group", :object_id => "#{group.id}"},
|
||||
:remote => true, :method => 'delete',
|
||||
:id => "#{group.id}", :style => "padding: 8px 8px 4px; ",
|
||||
:id => "#{group.id}", :style => "padding: 2px 8px 2px; background-color:#15bccf; color:#fff; ",
|
||||
:confirm => l(:text_are_you_sure_out_group), :class => 'group_in'
|
||||
|
||||
end
|
||||
else
|
||||
text = l(:label_new_join_group)
|
||||
form_tag({:controller => "courses", :action => "join_group", :object_id => "#{group.id}"}, :remote => true, :method => 'post') do
|
||||
submit_tag text, class: "group_in", style: "width: 90px;height: 21px;"
|
||||
submit_tag text, class: "group_in", style: "width: 90px;height: 21px; background-color:#15bccf; color:#fff;"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,9 +2,23 @@ class Activity < ActiveRecord::Base
|
|||
attr_accessible :act_id, :act_type, :user_id
|
||||
belongs_to :act, :polymorphic => true
|
||||
belongs_to :user
|
||||
belongs_to :activity_container, polymorphic: true
|
||||
validates :act_id, presence: true
|
||||
validates :act_type, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
include Trustie::Cache::ClearCourseEvent
|
||||
|
||||
before_create :set_container_type_val
|
||||
|
||||
#helper :activities
|
||||
include ActivitiesHelper
|
||||
def set_container_type_val
|
||||
params =get_container_type(self)
|
||||
self.activity_container_type = params[0]
|
||||
self.activity_container_id = params[1]
|
||||
if(self.act_type == 'JournalsForMessage')
|
||||
self.user_id = params[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ class Attachment < ActiveRecord::Base
|
|||
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# end
|
||||
include UserScoreHelper
|
||||
|
||||
|
|
@ -71,8 +73,8 @@ class Attachment < ActiveRecord::Base
|
|||
cattr_accessor :thumbnails_storage_path
|
||||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
|
||||
before_save :files_to_final_location,:act_as_course_activity
|
||||
after_create :office_conver, :be_user_score,:act_as_forge_activity
|
||||
after_update :office_conver, :be_user_score
|
||||
after_destroy :delete_from_disk,:down_user_score
|
||||
|
||||
|
|
@ -552,4 +554,10 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.container_type == "Course" && self.course_acts.empty?
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ class Course < ActiveRecord::Base
|
|||
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
||||
|
||||
has_many :course_groups, :dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
||||
has_many :course_activities
|
||||
has_many :course_messages
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
|
|
@ -44,7 +49,7 @@ class Course < ActiveRecord::Base
|
|||
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
|
||||
validates_length_of :description, :maximum => 10000
|
||||
before_save :self_validate
|
||||
after_create :create_board_sync
|
||||
after_create :create_board_sync, :act_as_course_activity
|
||||
before_destroy :delete_all_members
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
|
@ -310,6 +315,11 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
|
||||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
#def name
|
||||
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
class CourseActivity < ActiveRecord::Base
|
||||
attr_accessible :user_id, :course_act_id,:course_act_type,:course_id
|
||||
# 虚拟关联
|
||||
belongs_to :course_act ,:polymorphic => true
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed
|
||||
|
||||
# 多态 虚拟关联
|
||||
belongs_to :course_message ,:polymorphic => true
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
validates :user_id,presence: true
|
||||
validates :course_id,presence: true
|
||||
validates :course_message_id,presence: true
|
||||
validates :course_message_type, presence: true
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class Dts < ActiveRecord::Base
|
||||
attr_accessible :Category, :Defect, :Description, :File, :IPLine, :IPLineCode, :Method, :Num, :PreConditions, :Review, :StartLine, :TraceInfo, :Variable, :project_id
|
||||
|
||||
belongs_to :project
|
||||
end
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
class ForgeMessage < ActiveRecord::Base
|
||||
# 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT
|
||||
TYPE_OF_ISSUE_ACT = "Issue"
|
||||
TYPE_OF_MESSAGE_ACT = "Message"
|
||||
TYPE_OF_ATTACHMENT_ACT = "Attachment"
|
||||
TYPE_OF_DOCUMENT_ACT = "Document"
|
||||
TYPE_OF_JOURNAL_ACT = "Journal"
|
||||
TYPE_OF_WIKI_ACT = "Wiki"
|
||||
TYPE_OF_NEWS_ACT = "News"
|
||||
|
||||
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed
|
||||
|
||||
belongs_to :forge_message ,:polymorphic => true
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
validates :user_id,presence: true
|
||||
validates :project_id,presence: true
|
||||
validates :forge_message_id,presence: true
|
||||
validates :forge_message_type, presence: true
|
||||
end
|
||||
|
|
@ -13,17 +13,40 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
has_many :student_works, :dependent => :destroy
|
||||
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
acts_as_attachable
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
|
||||
:description => :description,
|
||||
:author => :author,
|
||||
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
|
||||
after_create :act_as_activity, :send_mail
|
||||
after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.user_id)
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程作业消息记录
|
||||
def act_as_course_message
|
||||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#删除对应的图片
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
class HomeworkTest < ActiveRecord::Base
|
||||
attr_accessible :input, :output, :homework_common_id
|
||||
attr_accessible :input, :output, :homework_common_id,:result,:error_msg
|
||||
|
||||
belongs_to :homework_common
|
||||
has_many :student_work_test
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ class Issue < ActiveRecord::Base
|
|||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
# ForgeMessage虚拟关联(多态)
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
|
||||
|
||||
|
||||
acts_as_nested_set :scope => 'root_id', :dependent => :destroy
|
||||
|
|
@ -80,7 +82,7 @@ class Issue < ActiveRecord::Base
|
|||
attr_reader :current_journal
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
# after_create :be_user_score
|
||||
|
|
@ -138,6 +140,16 @@ class Issue < ActiveRecord::Base
|
|||
:project_id => self.project_id)
|
||||
end
|
||||
# end
|
||||
|
||||
# 发布缺陷forge_messages中添加记录
|
||||
def act_as_forge_message
|
||||
# 指派给自己的缺陷不提示消息
|
||||
unless self.author_id == self.assigned_to_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id,
|
||||
:project_id => self.project_id,
|
||||
:viewed => false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||
|
|
@ -235,9 +247,10 @@ class Issue < ActiveRecord::Base
|
|||
base_reload(*args)
|
||||
end
|
||||
|
||||
def to_param
|
||||
@to_param ||= "#{id}_#{self.project.name}(#{self.project.issues.index(self).to_i+1}-#{self.project.issues.count})"#.parameterize
|
||||
end
|
||||
# 之所以注释是以为最终以id形式显示,另外如果项目名称带点号或者纯数字会出现问题
|
||||
# def to_param
|
||||
# @to_param ||= "#{id}_#{self.project.name}(#{self.project.issues.index(self).to_i+1}-#{self.project.issues.count})"#.parameterize
|
||||
# end
|
||||
|
||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||
def available_custom_fields
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class Journal < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 被ForgeMessage虚拟关联
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
|
||||
# end
|
||||
attr_accessor :indice
|
||||
|
||||
|
|
@ -48,7 +50,7 @@ class Journal < ActiveRecord::Base
|
|||
before_create :split_private_notes
|
||||
|
||||
# fq
|
||||
after_save :act_as_activity,:be_user_score,:act_as_forge_activity
|
||||
after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message
|
||||
# end
|
||||
#after_destroy :down_user_score
|
||||
#before_save :be_user_score
|
||||
|
|
@ -163,10 +165,17 @@ class Journal < ActiveRecord::Base
|
|||
# Description 公共表中需要保存一份该记录
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.user_id,
|
||||
:project_id => self.issue.project.id)
|
||||
:project_id => self.issue.project.id)
|
||||
|
||||
end
|
||||
|
||||
# 缺陷状态更改,消息提醒
|
||||
def act_as_forge_message
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id,
|
||||
:project_id => self.issue.project_id,
|
||||
:viewed => false)
|
||||
end
|
||||
|
||||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
|
|
|
|||
|
|
@ -56,9 +56,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
acts_as_attachable
|
||||
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
||||
validates :notes, presence: true, if: :is_homework_jour?
|
||||
after_create :act_as_activity #huang
|
||||
after_create :act_as_activity, :act_as_course_activity
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
|
@ -177,4 +179,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,7
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.jour_type == 'Course'
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -388,7 +388,8 @@ class Mailer < ActionMailer::Base
|
|||
@user = applied.user
|
||||
recipients = @project.manager_recipients
|
||||
s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
|
||||
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
|
||||
@token = Token.get_token_from_user(@user, 'autologin')
|
||||
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members', :token => @token.value)
|
||||
mail :to => recipients,
|
||||
:subject => s
|
||||
end
|
||||
|
|
|
|||
|
|
@ -143,6 +143,10 @@ class Member < ActiveRecord::Base
|
|||
StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
|
||||
end
|
||||
|
||||
def student_work_score_sum
|
||||
StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").sum(:final_score).try(:round, 2).to_f
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def validate_role
|
||||
|
|
|
|||
|
|
@ -32,7 +32,12 @@ class Message < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# end
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
|
|
@ -68,7 +73,7 @@ class Message < ActiveRecord::Base
|
|||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
|
||||
|
||||
after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail
|
||||
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_course_message, :send_mail
|
||||
#before_save :be_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
|
@ -185,6 +190,61 @@ class Message < ActiveRecord::Base
|
|||
:project_id => self.board.project.id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
# 课程讨论区添加消息
|
||||
# 老师发帖所有人都能收到消息
|
||||
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
|
||||
# 帖子被回复的可以收到消息通知
|
||||
def act_as_course_message
|
||||
if self.course
|
||||
if self.parent_id.nil? #主贴
|
||||
self.course.members.each do |m|
|
||||
if self.author.allowed_to?(:as_teacher, self.course) # 老师
|
||||
if m.user_id != self.author_id # 自己的帖子不给自己发送消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
else # 回帖
|
||||
#if self.author.allowed_to?(:as_teacher, self.course) # 老师
|
||||
self.course.members.each do |m|
|
||||
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
# if self.author.allowed_to?(:as_teacher, self.course) # 如果发帖人是老师
|
||||
# self.course.members.each do |m|
|
||||
# if self.parent_id.nil? # 主贴
|
||||
# if m.user_id != self.author_id # 自己的帖子不给自己发送消息
|
||||
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# else # 回帖只针对主贴发送消息
|
||||
# if m.user_id == Message.find(self.parent_id).author_id
|
||||
# self.course_messages << CourseMessage.new(:user_id => self.parent_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else # 学生只针对主贴回复
|
||||
# unless self.parent_id.nil?
|
||||
# self.course.members.each do |m|
|
||||
# if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
|
|
|
|||
|
|
@ -28,7 +28,12 @@ class News < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# end
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
|
|
@ -49,7 +54,7 @@ class News < ActiveRecord::Base
|
|||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
|
||||
after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail
|
||||
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_course_messge, :add_author_as_watcher, :send_mail
|
||||
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
|
|
@ -121,6 +126,25 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程通知 消息发送
|
||||
#消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
|
||||
def act_as_course_messge
|
||||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
# Description 删除news后删除对应的资源
|
||||
|
|
@ -132,4 +156,4 @@ class News < ActiveRecord::Base
|
|||
Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
class OptionNumber < ActiveRecord::Base
|
||||
attr_accessible :attachment, :changeset, :document, :follow, :issue_done_ratio, :issues_status, :memo, :messages_for_issues, :post_issue, :praise_by_one, :praise_by_three, :praise_by_two, :replay_for_memo, :replay_for_message, :score_type, :total_score, :tread, :tread_by_one, :tread_by_three, :tread_by_two, :user_id
|
||||
attr_accessible :attachment, :changeset, :document, :follow, :issue_done_ratio, :issues_status, :memo, :messages_for_issues, :post_issue,
|
||||
:praise_by_one, :praise_by_three, :praise_by_two, :replay_for_memo, :replay_for_message, :score_type, :total_score, :tread, :tread_by_one, :tread_by_three, :tread_by_two, :user_id
|
||||
|
||||
def self.get_user_option_number user_id
|
||||
result = nil
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ class Poll < ActiveRecord::Base
|
|||
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
||||
# 添加课程的poll动态
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
after_create :act_as_activity
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
after_create :act_as_activity, :act_as_course_activity
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
|
||||
:description => :polls_description,
|
||||
|
|
@ -27,4 +32,26 @@ class Poll < ActiveRecord::Base
|
|||
self.acts << Activity.new(:user_id => self.user_id)
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.polls_type == "Course"
|
||||
if self.polls_status == 2 #问卷是发布状态
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
|
||||
elsif self.polls_status == 1 #问卷是新建状态
|
||||
self.course_acts.destroy_all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 发布问卷,出了发布者外,其他人都能收到消息通知
|
||||
def act_as_course_message
|
||||
if self.polls_type == "Course"
|
||||
Course.find(self.polls_group_id).members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class Project < ActiveRecord::Base
|
|||
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
|
||||
has_many :applied_projects
|
||||
has_many :invite_lists
|
||||
has_one :dts
|
||||
|
||||
# end
|
||||
#ADDED BY NIE
|
||||
|
|
@ -90,6 +91,8 @@ class Project < ActiveRecord::Base
|
|||
|
||||
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
||||
has_many :project_tags, :class_name => 'ProjectTags'
|
||||
# 关联虚拟表
|
||||
has_many :forge_messages
|
||||
|
||||
belongs_to :organization
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@ class Repository::Git < Repository
|
|||
'Git'
|
||||
end
|
||||
|
||||
def commits(authors, start_date, end_date, branch='master')
|
||||
scm.commits(authors, start_date, end_date,branch).map {|commit|
|
||||
[commit[:author], commit[:num]]
|
||||
}
|
||||
end
|
||||
|
||||
def report_last_commit
|
||||
extra_report_last_commit
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@ class StudentWork < ActiveRecord::Base
|
|||
has_many :student_works_evaluation_distributions, :dependent => :destroy
|
||||
has_many :student_works_scores, :dependent => :destroy
|
||||
belongs_to :project
|
||||
has_many :student_work_test
|
||||
|
||||
before_destroy :delete_praise
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
def delete_praise
|
||||
PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
# encoding: utf-8
|
||||
class StudentWorkTest < ActiveRecord::Base
|
||||
attr_accessible :student_work_id, :homework_test_id, :result, :error_msg
|
||||
|
||||
belongs_to :homework_test
|
||||
belongs_to :student_work
|
||||
|
||||
def status_to_s
|
||||
case self.result.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
'答题错误'
|
||||
when -3
|
||||
'答案错误'
|
||||
when 1
|
||||
'运行出错'
|
||||
when 2
|
||||
'超时'
|
||||
when 3
|
||||
'内存超出'
|
||||
when 4
|
||||
'输出超出'
|
||||
when 5
|
||||
'禁用函数'
|
||||
when 6
|
||||
'其他错误'
|
||||
when 0
|
||||
'成功'
|
||||
else
|
||||
'未知错误'
|
||||
end
|
||||
end
|
||||
|
||||
def test_score
|
||||
if self.result.to_i == 0
|
||||
format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count)
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -66,9 +66,9 @@ class User < Principal
|
|||
|
||||
#每日一报、一事一报、不报
|
||||
MAIL_NOTIFICATION_OPTIONS = [
|
||||
['all', :label_user_mail_option_all],
|
||||
#['week', :label_user_mail_option_week],
|
||||
['day', :label_user_mail_option_day],
|
||||
['all', :label_user_mail_option_all],
|
||||
['none', :label_user_mail_option_none]
|
||||
]
|
||||
|
||||
|
|
@ -109,7 +109,6 @@ class User < Principal
|
|||
has_many :contests, :foreign_key => 'author_id', :dependent => :destroy
|
||||
has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
|
||||
has_many :journal_replies, :dependent => :destroy
|
||||
has_many :activities, :dependent => :destroy
|
||||
has_many :students_for_courses
|
||||
|
|
@ -128,8 +127,15 @@ class User < Principal
|
|||
has_many :messages, :foreign_key => 'author_id'
|
||||
has_one :user_score, :dependent => :destroy
|
||||
has_many :documents # 项目中关联的文档再次与人关联
|
||||
# 关联虚拟表
|
||||
has_many :forge_messages
|
||||
has_many :course_messages
|
||||
# end
|
||||
|
||||
# 虚拟转换
|
||||
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
|
||||
has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"'
|
||||
has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"'
|
||||
# 邮件邀请状态
|
||||
# has_many :invite_lists
|
||||
# end
|
||||
|
|
@ -235,6 +241,28 @@ class User < Principal
|
|||
|
||||
# ======================================================================
|
||||
|
||||
# 查询用户未读过的记录
|
||||
# 用户留言记录
|
||||
def count_new_jour
|
||||
count = self.new_jours.count
|
||||
# count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count
|
||||
end
|
||||
|
||||
# 查询指派给我的缺陷记录
|
||||
def count_new_issue_assign_to
|
||||
self.issue_assigns
|
||||
end
|
||||
|
||||
# 新消息统计
|
||||
def count_new_message
|
||||
count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count
|
||||
end
|
||||
# 查询指派给我的缺陷记录
|
||||
def issue_status_update
|
||||
self.status_updates
|
||||
end
|
||||
# end
|
||||
|
||||
def extensions
|
||||
self.user_extensions ||= UserExtensions.new
|
||||
end
|
||||
|
|
@ -258,7 +286,7 @@ class User < Principal
|
|||
###添加留言 fq
|
||||
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, :status => true)
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true, :is_readed => false)
|
||||
else
|
||||
jfm = self.journals_for_messages.build(options)
|
||||
jfm.save
|
||||
|
|
@ -291,11 +319,7 @@ class User < Principal
|
|||
name
|
||||
end
|
||||
## end
|
||||
|
||||
def count_new_jour
|
||||
count = self.new_jours.count
|
||||
end
|
||||
|
||||
|
||||
#added by nie
|
||||
def count_new_journal_reply
|
||||
count = self.journal_reply.count
|
||||
|
|
@ -418,7 +442,7 @@ class User < Principal
|
|||
end
|
||||
|
||||
def nickname(formatter = nil)
|
||||
login
|
||||
login.nil? || (login && login.empty?) ? "AnonymousUser" : login
|
||||
end
|
||||
|
||||
def name(formatter = nil)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ class UserExtensions < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :school, :class_name => 'School', :foreign_key => :school_id
|
||||
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id
|
||||
validates_length_of :description, :maximum => 255
|
||||
validates_length_of :brief_introduction, :maximum => 255
|
||||
TEACHER = 0
|
||||
STUDENT = 1
|
||||
ENTERPRISE = 2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
class Visitor < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
@ -112,6 +112,9 @@ class CommentService
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# 获取课程里的某个通知的所有回复
|
||||
def notice_comments params,current_user
|
||||
News.find(params[:notice_id]).comments.page(params[:page] || 1).per(10)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -4,6 +4,7 @@ class CoursesService
|
|||
include CoursesHelper
|
||||
include HomeworkAttachHelper
|
||||
include ApiHelper
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
#参数school_id为0或不传时返回所有课程,否则返回对应学校的课程
|
||||
#参数per_page_count分页功能,每页显示的课程数
|
||||
|
|
@ -332,13 +333,13 @@ class CoursesService
|
|||
def homework_list params,current_user
|
||||
course = Course.find(params[:id])
|
||||
if course.is_public != 0 || current_user.member_of_course?(course)
|
||||
bids = course.homework_commons.page(1).per(20).order('created_at DESC')
|
||||
bids = course.homework_commons.page(params[:page] || 1).per(20).order('created_at DESC')
|
||||
bids = bids.like(params[:name]) if params[:name].present?
|
||||
homeworks = []
|
||||
bids.each do |bid|
|
||||
homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course))
|
||||
end
|
||||
homeworks
|
||||
homeworks = []
|
||||
bids.each do |bid|
|
||||
homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course))
|
||||
end
|
||||
homeworks
|
||||
else
|
||||
raise '403'
|
||||
end
|
||||
|
|
@ -551,17 +552,28 @@ class CoursesService
|
|||
else
|
||||
end
|
||||
end
|
||||
studentlist = []
|
||||
bid.student_works.order("created_at desc").page(1).per(6).each do |work|
|
||||
studentlist << work.user
|
||||
end
|
||||
unless is_course_teacher
|
||||
homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user
|
||||
end
|
||||
# studentlist = []
|
||||
# bid.student_works.order("created_at desc").page(1).per(6).each do |work|
|
||||
# studentlist << work.user
|
||||
# end
|
||||
# unless is_course_teacher
|
||||
# homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user
|
||||
# end
|
||||
#end
|
||||
open_anonymous_evaluation = bid.homework_detail_manual.comment_status
|
||||
{:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.user,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0,
|
||||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_at,:deadline => bid.end_time,:studentlist => studentlist}
|
||||
{:course_name => course.name,:course_id => course.id,:id => bid.id,
|
||||
:author => bid.user,:author_real_name => author_real_name,
|
||||
:homework_times => many_times, :homework_name => name,
|
||||
:homework_count => homework_count,:student_questions_count => 0,
|
||||
:description => description, :homework_state => state,
|
||||
:open_anonymous_evaluation => open_anonymous_evaluation,
|
||||
#:homework_for_anonymous_comments => homework_for_anonymous_comments,
|
||||
:created_on => bid.created_at,:deadline => bid.end_time,
|
||||
:homework_notsubmit_num => bid.course.members.count - bid.student_works.count,
|
||||
:homework_submit_num => bid.student_works.count,
|
||||
:homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid),
|
||||
:student_evaluation_part => get_evaluation_part( bid ,3),
|
||||
:ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?}
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -642,47 +654,42 @@ class CoursesService
|
|||
return
|
||||
end
|
||||
if current_user == @user || current_user.admin?
|
||||
membership = @user.coursememberships.page(1).per(15)
|
||||
membership = @user.coursememberships
|
||||
else
|
||||
membership = @user.coursememberships.page(1).per(15).all(:conditions => Course.visible_condition(current_user))
|
||||
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
|
||||
end
|
||||
if membership.nil? || membership.count == 0
|
||||
raise l(:label_no_courses, :locale => get_user_language(current_user))
|
||||
end
|
||||
membership.sort! { |older, newer| newer.created_on <=> older.created_on }
|
||||
#membership.sort! { |older, newer| newer.created_on <=> older.created_on }
|
||||
|
||||
#定义一个数组集合,存放hash数组,该hash数组包括课程的信息,并包含课程的最新发布的资源,最新的讨论区留言,最新的作业,最新的通知
|
||||
result = []
|
||||
#对用户所有的课程进行循环,找到每个课程最新发布的资源,最新的讨论区留言,最新的作业,最新的通知,并存进数组
|
||||
|
||||
membership.each do |mp|
|
||||
course = mp.course
|
||||
latest_course_dynamics = []
|
||||
dynamics_count = 0
|
||||
# 课程学霸 学生总分数排名靠前的5个人
|
||||
homework_count = course.homework_commons.count
|
||||
sql = "select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{course.id}) GROUP BY student_works.user_id ORDER BY score limit 0,6"
|
||||
better_students = User.find_by_sql(sql)
|
||||
if homework_count != 0 && !better_students.empty?
|
||||
latest_course_dynamics <<{:type=> 6,:time=>Time.now.to_s,:count=> 6,:better_students=> better_students}
|
||||
dynamics_count += 1
|
||||
end
|
||||
notices_count = 0
|
||||
topic_count = 0
|
||||
topics = nil
|
||||
homeworkss = nil
|
||||
notices = nil
|
||||
|
||||
# 课程通知
|
||||
latest_news = course.news.page(1).per(2).order("created_on desc")
|
||||
unless latest_news.first.nil?
|
||||
latest_course_dynamics << {:type => 1, :time => latest_news.first.created_on,:count=>course.news.count,
|
||||
:news => latest_news.all}
|
||||
dynamics_count += 1
|
||||
notices_count = course.news.count
|
||||
notices = latest_news.all
|
||||
latest_course_dynamics << {:time => latest_news.first.created_on }
|
||||
end
|
||||
|
||||
# 课程讨论区
|
||||
# latest_message = course.boards.first.topics.page(1).per(2)
|
||||
# unless latest_message.first.nil?
|
||||
# latest_course_dynamics << {:type => 2, :time => latest_message.first.created_on, :count =>course.boards.nil? ? 0 : course.boards.first.topics.count,
|
||||
# :topics => latest_message.all}
|
||||
# dynamics_count += 1
|
||||
# end
|
||||
|
||||
latest_message = course.boards.first.topics.page(1).per(2)
|
||||
unless latest_message.first.nil?
|
||||
topic_count = course.boards.nil? ? 0 : course.boards.first.topics.count
|
||||
topics = latest_message.all
|
||||
latest_course_dynamics << {:time => latest_message.first.created_on}
|
||||
end
|
||||
# 课程资源
|
||||
# latest_attachment = course.attachments.order("created_on desc").page(1).per(2)
|
||||
# unless latest_attachment.first.nil?
|
||||
|
|
@ -693,32 +700,96 @@ class CoursesService
|
|||
#课程作业 已经交的学生列表(暂定显示6人),未交的学生列表,作业的状态
|
||||
homeworks = course.homework_commons.page(1).per(2).order('created_at desc')
|
||||
unless homeworks.first.nil?
|
||||
latest_course_dynamics << {:type => 4, :time => homeworks.first.updated_at, :count=>course.homework_commons.count , :homeworks => homeworks}
|
||||
dynamics_count += 1
|
||||
homeworkss = homeworks
|
||||
latest_course_dynamics << {:time => homeworks.first.updated_at}
|
||||
end
|
||||
latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
# 课程学霸 学生总分数排名靠前的5个人
|
||||
homework_count = course.homework_commons.count
|
||||
sql = "select users.*,ROUND(sum(student_works.final_score),2) score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{course.id}) GROUP BY student_works.user_id ORDER BY score desc limit 0,4"
|
||||
|
||||
better_students = User.find_by_sql(sql)
|
||||
|
||||
# 找出在课程讨论区发帖回帖数最多的
|
||||
active_students = []
|
||||
sql1 = " select users.*,count(author_id)*2 active_count from messages " <<
|
||||
" LEFT JOIN users on messages.author_id = users.id " <<
|
||||
" where messages.board_id in (select id from boards where boards.course_id = #{course.id} ) " <<
|
||||
" GROUP BY messages.author_id ORDER BY count(author_id) desc " <<
|
||||
" limit 0,4"
|
||||
active_students = User.find_by_sql(sql1)
|
||||
|
||||
if homework_count != 0 && !better_students.empty?
|
||||
latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"}
|
||||
end
|
||||
unless active_students.empty?
|
||||
latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"}
|
||||
end
|
||||
latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
latest_course_dynamic = latest_course_dynamics.first
|
||||
unless latest_course_dynamic.nil?
|
||||
result << {:course_name => course.name, :course_id => course.id, :course_img_url => url_to_avatar(course), :course_time => course.time, :course_term => course.term,:message => dynamics_count, :dynamics => latest_course_dynamics, :count => dynamics_count}
|
||||
result << {:course_name => course.name,
|
||||
:current_user_is_member => current_user.member_of_course?(course),
|
||||
:current_user_is_teacher => is_course_teacher(current_user,course),
|
||||
:course_id => course.id,
|
||||
:course_img_url => url_to_avatar(course),
|
||||
:course_time => course.time,
|
||||
:course_term => course.term,
|
||||
:news_count => notices_count,
|
||||
:homework_count => homework_count,
|
||||
:topic_count => topic_count,
|
||||
:news => notices,
|
||||
:homeworks => homeworkss,
|
||||
:topics => topics,
|
||||
:better_students => better_students,
|
||||
:active_students => active_students,
|
||||
:message => "",
|
||||
:course_student_num=>course ? course.members.count : 0,
|
||||
#:time_from_now=> distance_of_time_in_words(Time.now, latest_course_dynamic[:time].to_time) << "前",
|
||||
:time_from_now=>time_from_now(latest_course_dynamic[:time].to_time), #.strftime('%Y-%m-%d %H:%M:%S').to_s,
|
||||
:time=>latest_course_dynamic[:time].to_time}
|
||||
end
|
||||
|
||||
end
|
||||
#返回数组集合
|
||||
result.sort! { |order, newer| newer[:update_time] <=> order[:update_time] }
|
||||
result.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# 获取课程历次作业的学生总成绩
|
||||
def students_score_list params,current_user
|
||||
homework_count = Course.find(params[:course_id]).homework_commons.count
|
||||
page = (params[:page] || 1) - 1
|
||||
sql = "select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score limit #{page*10},10"
|
||||
User.find_by_sql(sql)
|
||||
user_list = []
|
||||
max_size = 0
|
||||
if params[:type] == 1
|
||||
|
||||
sql = "select users.*,ROUND(sum(student_works.final_score),2) score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score desc limit #{page*10},10"
|
||||
sql_count = " select count(distinct(student_works.user_id) ) " <<
|
||||
" from student_works left outer join users on student_works.user_id = users.id " <<
|
||||
" where homework_common_id in " <<
|
||||
" ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) "
|
||||
max_size = ActiveRecord::Base.connection().select_value(sql_count)
|
||||
user_list = User.find_by_sql(sql)
|
||||
else
|
||||
sql1 = " select users.*,count(author_id)*2 active_count from messages " <<
|
||||
" LEFT JOIN users on messages.author_id = users.id " <<
|
||||
" where messages.board_id in (select id from boards where boards.course_id = #{params[:course_id]} ) " <<
|
||||
" GROUP BY messages.author_id ORDER BY count(author_id) desc " <<
|
||||
" limit #{page*10},10"
|
||||
sql1_count = " select count(DISTINCT(messages.author_id))" <<
|
||||
" from messages LEFT JOIN users on messages.author_id = users.id " <<
|
||||
" where messages.board_id in (select id from boards where boards.course_id = #{params[:course_id]} )"
|
||||
max_size = ActiveRecord::Base.connection().select_value(sql1_count)
|
||||
user_list = User.find_by_sql(sql1)
|
||||
end
|
||||
{:user_list=>user_list,:max_size=>max_size}
|
||||
end
|
||||
|
||||
# 获取某次作业的所有作业列表
|
||||
def student_work_list params,current_user
|
||||
is_teacher = User.current.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
is_teacher = current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
student_works = []
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
|
|
@ -746,41 +817,80 @@ class CoursesService
|
|||
student_works
|
||||
end
|
||||
|
||||
# 开启匿评
|
||||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
def start_anonymous_comment params,current_user
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
return {:status=>4} unless current_user.admin? || current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
return {:status=>5} if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
if homework_detail_manual.comment_status == 1
|
||||
student_works = homework.student_works
|
||||
if student_works && student_works.size >=2
|
||||
student_works.each_with_index do |work, index|
|
||||
user = work.user
|
||||
n = homework_detail_manual.evaluation_num
|
||||
n = n < student_works.size ? n : student_works.size - 1
|
||||
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
|
||||
assigned_homeworks.each do |h|
|
||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
||||
student_works_evaluation_distributions.save
|
||||
end
|
||||
end
|
||||
homework_detail_manual.update_column('comment_status', 2)
|
||||
statue = 1
|
||||
else
|
||||
statue = 2
|
||||
end
|
||||
else
|
||||
statue = 3
|
||||
end
|
||||
{:status => statue}
|
||||
# 获取课程的讨论区信息
|
||||
def board_message_list params,current_user
|
||||
# 课程讨论区
|
||||
course = Course.find(params[:course_id])
|
||||
latest_message = course.boards.first.topics.page(params[:page] || 1).per(10)
|
||||
end
|
||||
|
||||
def get_assigned_homeworks(student_works, n, index)
|
||||
student_works += student_works
|
||||
student_works[index + 1 .. index + n]
|
||||
#获取回复列表
|
||||
def board_message_reply_list params,current_user
|
||||
board = Board.find(params[:board_id])
|
||||
reply_list = board.topics.where("id = #{params[:msg_id]}").first.children.order("created_on desc").page(params[:page] || 1).per(10)
|
||||
end
|
||||
|
||||
#回复讨论区
|
||||
def board_message_reply params,current_user
|
||||
author = Message.find(params[:parent_id]).author
|
||||
quote = "<blockquote>" << author.realname << "(" << author.nickname << ")写到: <br/>" << params[:quote] <<"<div class='cl'></div></blockquote>"
|
||||
reply = Message.new
|
||||
reply.author = current_user
|
||||
reply.board = Board.find(params[:board_id])
|
||||
params[:reply] = {}
|
||||
params[:reply][:subject] = params[:subject] #本回复标题
|
||||
params[:reply][:content] = params[:content] #本回复内容
|
||||
params[:reply][:quote] = {}
|
||||
params[:reply][:quote][:quote] = params[:quote] #本回复引用的内容,也是父id内容
|
||||
params[:reply][:parent_topic] = params[:parent_id] # 父id
|
||||
params[:reply][:board_id] = params[:board_id] #讨论区id
|
||||
params[:reply][:id] = params[:root_id] #根id
|
||||
reply.safe_attributes = params[:reply]
|
||||
if params[:root_id] == params[:parent_id]
|
||||
reply.content = reply.content
|
||||
else
|
||||
reply.content = quote + reply.content
|
||||
end
|
||||
|
||||
Message.find(params[:root_id]).children << reply
|
||||
reply
|
||||
end
|
||||
|
||||
# # 开启匿评
|
||||
# #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
# def start_anonymous_comment params,current_user
|
||||
# homework = HomeworkCommon.find(params[:homework_id])
|
||||
# return {:status=>4} unless current_user.admin? || current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
# return {:status=>5} if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
# homework_detail_manual = homework.homework_detail_manual
|
||||
# if homework_detail_manual.comment_status == 1
|
||||
# student_works = homework.student_works
|
||||
# if student_works && student_works.size >=2
|
||||
# student_works.each_with_index do |work, index|
|
||||
# user = work.user
|
||||
# n = homework_detail_manual.evaluation_num
|
||||
# n = n < student_works.size ? n : student_works.size - 1
|
||||
# assigned_homeworks = get_assigned_homeworks(student_works, n, index)
|
||||
# assigned_homeworks.each do |h|
|
||||
# student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
||||
# student_works_evaluation_distributions.save
|
||||
# end
|
||||
# end
|
||||
# homework_detail_manual.update_column('comment_status', 2)
|
||||
# statue = 1
|
||||
# else
|
||||
# statue = 2
|
||||
# end
|
||||
# else
|
||||
# statue = 3
|
||||
# end
|
||||
# {:status => statue}
|
||||
# end
|
||||
#
|
||||
# def get_assigned_homeworks(student_works, n, index)
|
||||
# student_works += student_works
|
||||
# student_works[index + 1 .. index + n]
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,47 +57,97 @@ class HomeworkService
|
|||
[@bid,@totle_size,@cur_size,@percent]
|
||||
end
|
||||
|
||||
#启动匿评
|
||||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启
|
||||
def start_anonymous_comment params,current_user
|
||||
@bid = Bid.find(params[:id])
|
||||
@course = @bid.courses.first
|
||||
unless is_course_teacher(current_user,@course) || current_user.admin?
|
||||
@statue = 4
|
||||
raise '403'
|
||||
end
|
||||
if(@bid.comment_status == 0)
|
||||
homeworks = @bid.homeworks
|
||||
if(homeworks && homeworks.size >= 2)
|
||||
homeworks.each_with_index do |homework, index|
|
||||
user = homework.user
|
||||
n = @bid.evaluation_num
|
||||
n = n < homeworks.size ? n : homeworks.size - 1
|
||||
assigned_homeworks = get_assigned_homeworks(homeworks, n, index)
|
||||
assigned_homeworks.each do |h|
|
||||
@homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id)
|
||||
@homework_evaluation.save
|
||||
end
|
||||
end
|
||||
@bid.update_column('comment_status', 1)
|
||||
@statue = 1
|
||||
else
|
||||
@statue = 2
|
||||
end
|
||||
else
|
||||
@statue = 3
|
||||
end
|
||||
@statue
|
||||
end
|
||||
#关闭匿评
|
||||
def stop_anonymous_comment params,current_user
|
||||
@bid = Bid.find(params[:id])
|
||||
@course = @bid.courses.first
|
||||
unless is_course_teacher(current_user,@course) || current_user.admin?
|
||||
raise '403'
|
||||
end
|
||||
@bid.update_column('comment_status', 2)
|
||||
end
|
||||
# 启动匿评 操作 逻辑改变,暂不删除
|
||||
# #启动匿评
|
||||
# #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启
|
||||
# def start_anonymous_comment params,current_user
|
||||
# @bid = Bid.find(params[:id])
|
||||
# @course = @bid.courses.first
|
||||
# unless is_course_teacher(current_user,@course) || current_user.admin?
|
||||
# @statue = 4
|
||||
# raise '403'
|
||||
# end
|
||||
# if(@bid.comment_status == 0)
|
||||
# homeworks = @bid.homeworks
|
||||
# if(homeworks && homeworks.size >= 2)
|
||||
# homeworks.each_with_index do |homework, index|
|
||||
# user = homework.user
|
||||
# n = @bid.evaluation_num
|
||||
# n = n < homeworks.size ? n : homeworks.size - 1
|
||||
# assigned_homeworks = get_assigned_homeworks(homeworks, n, index)
|
||||
# assigned_homeworks.each do |h|
|
||||
# @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id)
|
||||
# @homework_evaluation.save
|
||||
# end
|
||||
# end
|
||||
# @bid.update_column('comment_status', 1)
|
||||
# @statue = 1
|
||||
# else
|
||||
# @statue = 2
|
||||
# end
|
||||
# else
|
||||
# @statue = 3
|
||||
# end
|
||||
# @statue
|
||||
# end
|
||||
# #关闭匿评
|
||||
# def stop_anonymous_comment params,current_user
|
||||
# @bid = Bid.find(params[:id])
|
||||
# @course = @bid.courses.first
|
||||
# unless is_course_teacher(current_user,@course) || current_user.admin?
|
||||
# raise '403'
|
||||
# end
|
||||
# @bid.update_column('comment_status', 2)
|
||||
# end
|
||||
|
||||
# 开启匿评
|
||||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
def start_anonymous_comment params,current_user
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
return {:status=> 4} unless current_user.admin? || current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
return {:status=>5} if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
if homework_detail_manual.comment_status == 1
|
||||
student_works = homework.student_works
|
||||
if student_works && student_works.size >=2
|
||||
student_works.each_with_index do |work, index|
|
||||
user = work.user
|
||||
n = homework_detail_manual.evaluation_num
|
||||
n = n < student_works.size ? n : student_works.size - 1
|
||||
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
|
||||
assigned_homeworks.each do |h|
|
||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
||||
student_works_evaluation_distributions.save
|
||||
end
|
||||
end
|
||||
homework_detail_manual.update_column('comment_status', 2)
|
||||
statue = 1
|
||||
else
|
||||
statue = 2
|
||||
end
|
||||
else
|
||||
statue = 3
|
||||
end
|
||||
{:status => statue}
|
||||
end
|
||||
|
||||
def get_assigned_homeworks(student_works, n, index)
|
||||
student_works += student_works
|
||||
student_works[index + 1 .. index + n]
|
||||
end
|
||||
|
||||
def stop_anonymous_comment params,current_user
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
homework_detail_manual = homework.homework_detail_manual
|
||||
homework_detail_manual.update_column('comment_status', 3)
|
||||
|
||||
work_ids = "(" << homework.student_works.map(&:id).join(",") << ")"
|
||||
homework.student_works.each do |student_work|
|
||||
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
|
||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
end
|
||||
|
||||
# 匿评作品详情
|
||||
# attachs 该作品的所有附件
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<div class="box tabular">
|
||||
<p>
|
||||
<label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||
<%= text_field_tag 'mail', nil, :size => 40 %>
|
||||
<%= text_field_tag 'mail', nil, :size => 40, :placeholder => '请输入注册邮箱'%>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
<div class="tabs">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_forum), {:action => 'messages_list'}, class: "#{current_page?(messages_list_path)? 'selected' : nil }" %></li>
|
||||
<li><%= link_to l(:label_borad_course), {:action => 'course_messages'}, class: "#{current_page?(course_messages_path)? 'selected' : nil }" %></li>
|
||||
<li><%= link_to l(:label_borad_project), {:action => 'project_messages'}, class: "#{current_page?(project_messages_path)? 'selected' : nil }" %></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<h3>
|
||||
<%=l(:label_message_plural)%>
|
||||
</h3>
|
||||
|
||||
<%= render 'tab_messages' %>
|
||||
<h4><%=l(:label_borad_course) %></h4>
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for course in @course_ms -%>
|
||||
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= Board.where('id=?',course.board_id).first.course_id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if course.try(:author).try(:realname) == ' '%><%= course.try(:author)%><% else %><%=course.try(:author).try(:realname) %><% end %>'>
|
||||
<% if course.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(course.try(:author), user_path(course.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(course.try(:author).try(:realname), user_path(course.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(course.created_on) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=course.subject %>'>
|
||||
<%= course.subject %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=course.replies_count %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<h3>
|
||||
<%=l(:label_user_homework)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
作业名称
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
课程名称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
提交作品数
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
提交截止日期
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%@count=0 %>
|
||||
<% for homework in @homework do %>
|
||||
<% @count+=1 %>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<%=@count %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=homework.name%>'>
|
||||
<%=link_to(homework.name, student_work_index_path(:homework => homework.id))%>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=homework.course.name%>'>
|
||||
<%= link_to(homework.course.name, course_path(homework.course.id)) %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if homework.try(:user).try(:realname) == ' '%><%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'>
|
||||
<% if homework.try(:user).try(:realname) == ' '%>
|
||||
<%= link_to(homework.try(:user), user_path(homework.user_id)) %>
|
||||
<% else %>
|
||||
<%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=StudentWork.where('homework_common_id=?',homework.id).count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_date(homework.end_time) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_user_homework)) -%>
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<h3>
|
||||
<%=l(:label_latest_login_user_list)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
登录时间
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
用户id
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
用户姓名
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
用户昵称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
用户身份
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0 %>
|
||||
<% for user in @user do %>
|
||||
<tr>
|
||||
<% @count +=1 %>
|
||||
<td align="center">
|
||||
<%=@count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_date(user.last_login_on) %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=user.id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if user.try(:realname) == ' '%><%= user.login%><% else %><%=user.try(:realname) %><% end %>'>
|
||||
<% if user.try(:realname) == ' '%>
|
||||
<%= link_to(user.login, user_path(user)) %>
|
||||
<% else %>
|
||||
<%= link_to(user.try(:realname), user_path(user)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=link_to(user.login, user_path(user)) %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<% case user.user_extensions.identity %>
|
||||
<% when 0 %>
|
||||
<%='老师' %>
|
||||
<% when 1 %>
|
||||
<%='学生' %>
|
||||
<% when 2 %>
|
||||
<%='企业' %>
|
||||
<% when 3 %>
|
||||
<%='开发者' %>
|
||||
<% else %>
|
||||
<%='未知身份' %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_latest_login_user_list)) -%>
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<h3>
|
||||
<%=l(:label_leave_message_list)%>
|
||||
</h3>
|
||||
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
类型
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
留言人
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
留言时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
留言内容
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for journal in @jour -%>
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%case journal.jour_type %>
|
||||
<% when 'Principal' %>
|
||||
<%='用户主页' %>
|
||||
<% when 'Course' %>
|
||||
<%='课程' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= journal.jour_id %>
|
||||
</td>
|
||||
<td align="center" title='<%= journal.try(:user).try(:realname)%>'>
|
||||
<%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(journal.created_on) %>
|
||||
</td>
|
||||
<td title='<%=journal.notes %>'>
|
||||
<%= journal.notes.truncate(15, omission: '...') %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<% if(journal.m_reply_count) %>
|
||||
<%=journal.m_reply_count%>
|
||||
<% else %>
|
||||
<%=0 %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @jour_pages, @jour_count %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_leave_message_list)) -%>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<h3>
|
||||
<%=l(:label_message_plural)%>
|
||||
</h3>
|
||||
|
||||
<%= render 'tab_messages' %>
|
||||
<h4><%=l(:label_forum) %></h4>
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for memo in @memo -%>
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= memo.forum_id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if memo.try(:author).try(:realname) == ' '%><%= memo.try(:author)%><% else %><%=memo.try(:author).try(:realname) %><% end %>'>
|
||||
<% if memo.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(memo.try(:author), user_path(memo.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(memo.try(:author).try(:realname), user_path(memo.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(memo.created_at) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=memo.subject %>'>
|
||||
<%= memo.subject %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=memo.replies_count %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--<div class="pagination">
|
||||
<ul>
|
||||
<#%= pagination_links_full @memo_pages, @memo_count %>
|
||||
</ul>
|
||||
</div>-->
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<h3>
|
||||
<%=l(:label_notification_list)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
课程id
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
课程名称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
主讲老师
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for news in @news -%>
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=news.course_id %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title="<%=news.course.name %>">
|
||||
<%=link_to(news.course.name, course_path(news.course)) %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title="<%=news.course.try(:teacher).try(:realname) %>">
|
||||
<%=link_to(news.course.try(:teacher).try(:realname), user_path(news.course.teacher)) %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if news.try(:author).try(:realname) == ' '%><%= news.try(:author)%><% else %><%=news.try(:author).try(:realname) %><% end %>'>
|
||||
<% if news.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(news.try(:author), user_path(news.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(news.try(:author).try(:realname), user_path(news.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(news.created_on) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=news.title %>'>
|
||||
<%= link_to(news.title, news_path(news)) %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=news.comments_count %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_notification_list)) -%>
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<h3>
|
||||
<%=l(:label_message_plural)%>
|
||||
</h3>
|
||||
|
||||
<%= render 'tab_messages' %>
|
||||
<h4><%=l(:label_borad_project) %></h4>
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for project in @project_ms -%>
|
||||
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= Board.where('id=?',project.board_id).first.project_id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if project.try(:author).try(:realname) == ' '%><%= project.try(:author)%><% else %><%=project.try(:author).try(:realname) %><% end %>'>
|
||||
<% if project.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(project.try(:author), user_path(project.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(project.try(:author).try(:realname), user_path(project.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(project.created_on) %>
|
||||
</td>
|
||||
<td title='<%=project.subject %>' style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name">
|
||||
<%= project.subject %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=project.replies_count %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<h3 style="float: left">
|
||||
<%=l(:label_school_plural)%>
|
||||
</h3>
|
||||
<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>
|
||||
<%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>
|
||||
<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>">
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="autoscroll" style="margin-top: 40px;">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
LOGO
|
||||
</th>
|
||||
<th>
|
||||
学校名称
|
||||
</th>
|
||||
<th style="width: 100px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @schools.each do |school|%>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align:center;vertical-align: middle;">
|
||||
<%= school.id %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= image_tag(school.logo_link,width:40,height:40) %>
|
||||
</td>
|
||||
<td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=school.name%>'>
|
||||
<span>
|
||||
<%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="buttons" style="vertical-align: middle;">
|
||||
<%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
|
||||
<%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_project_plural)) -%>
|
||||
|
|
@ -17,6 +17,8 @@ if (window.Messenger) {
|
|||
Messenger().post({
|
||||
id: "label_apply_project_waiting",
|
||||
message: "<%= l(:label_apply_project_waiting) %>",
|
||||
showCloseButton: true,
|
||||
showCloseButton: true
|
||||
});
|
||||
};
|
||||
|
||||
$("#applied_project_link_<%= @project.id%>").replaceWith("<%= escape_javascript(link_to "加入项目",appliedproject_path(:user_id => User.current.id,:project_id => @project.id,:project_join => true),:class => "blue_n_btn fr mt20", :remote => "true",:method => "post",:id => "applied_project_link_#{@project.id}") %>");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<% elsif @status == 2%>
|
||||
alert("<%= l('project.join.tips.success') %>");
|
||||
hideModal($("#popbox"));
|
||||
$("#applied_project_link_<%= @project.id%>").replaceWith("<%=escape_javascript(link_to '取消申请',appliedproject_applied_path(:project_id => @project.id,:user_id => User.current.id),:class => "blue_n_btn fr mt20", :remote => "true",:method => "delete",:id => "applied_project_link_#{@project.id}")%>");
|
||||
<% elsif @status == 3%>
|
||||
alert("<%= l('project.join.tips.has') %>");
|
||||
<%else%>
|
||||
|
|
|
|||
|
|
@ -29,32 +29,32 @@
|
|||
<% is_float ||= false %>
|
||||
<% for attachment in attachments %>
|
||||
<div style="float:left;">
|
||||
<p style="height:14px;line-height:12px;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%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_">
|
||||
<p style="height:14px;line-height:12px;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%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_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%>
|
||||
<% else %>
|
||||
<%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%>
|
||||
<% end %>
|
||||
</span>
|
||||
<%if is_float%>
|
||||
</div>
|
||||
<% end%>
|
||||
<%if is_float%>
|
||||
</div>
|
||||
<% end%>
|
||||
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments',
|
||||
:action => 'show',
|
||||
:id => attachment,
|
||||
:filename => attachment.filename%>
|
||||
<% end %>
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments',
|
||||
:action => 'show',
|
||||
:id => attachment,
|
||||
:filename => attachment.filename%>
|
||||
<% end %>
|
||||
</div>
|
||||
<div style="float:left;max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="<%= attachment.description%>">
|
||||
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||
</div>
|
||||
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||
</div>
|
||||
<span class="size">(
|
||||
<%= number_to_human_size attachment.filesize %>)
|
||||
</span>
|
||||
|
|
@ -66,6 +66,16 @@
|
|||
:class => 'delete delete-homework-icon',
|
||||
:remote => true,
|
||||
:title => l(:button_delete) %>
|
||||
<% elsif attachment.container_type == 'Issue' %>
|
||||
<% if User.current == attachment.author %>
|
||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:method => :delete,
|
||||
:class => 'delete',
|
||||
#:remote => true,
|
||||
#:id => "attachments_" + attachment.id.to_s,
|
||||
:title => l(:button_delete) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
|
|
@ -89,13 +99,13 @@
|
|||
</p>
|
||||
<% end %>
|
||||
<div class="thumbnails">
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = attachments.select(&:thumbnailable?) %>
|
||||
<% if images.any? %>
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = attachments.select(&:thumbnailable?) %>
|
||||
<% if images.any? %>
|
||||
<% images.each do |attachment| %>
|
||||
<div class="pro_pic fl " width="100" height="73"><%= thumbnail_issue_tag(attachment) %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
|
||||
</div>
|
||||
</span>
|
||||
<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
|
||||
<%= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
|
||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||
<span><%= l(:button_upload_photo) %></span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
<% if @source_type=='User' %>
|
||||
var imgSpan = $("img[nhname='avatar_image']");
|
||||
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
|
||||
<% else %>
|
||||
var imgSpan = jQuery('#avatar_image');
|
||||
|
||||
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
|
||||
|
||||
<% end %>
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<!-- huang -->
|
||||
<h3><%=l(:label_newtype_contest)%></h3>
|
||||
<!--<!– huang –>-->
|
||||
<!--<h3><%=l(:label_newtype_contest)%></h3>-->
|
||||
|
||||
<%= labelled_form_for @bid, :url => {:controller => 'bids', :action => 'create_contest'} do |f| %>
|
||||
<div class="box tabular">
|
||||
<%= render :partial => 'form_contest', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= javascript_tag "$('#bid_name').focus();" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<!--<%= labelled_form_for @bid, :url => {:controller => 'bids', :action => 'create_contest'} do |f| %>-->
|
||||
<!--<div class="box tabular">-->
|
||||
<!--<%= render :partial => 'form_contest', :locals => { :f => f } %>-->
|
||||
<!--<%= submit_tag l(:button_create) %>-->
|
||||
<!--<%= javascript_tag "$('#bid_name').focus();" %>-->
|
||||
<!--<% end %>-->
|
||||
<!--</div>-->
|
||||
|
|
@ -32,33 +32,31 @@
|
|||
<hr/>
|
||||
</div>
|
||||
<% end %>
|
||||
<p class="c_dark mb5">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
|
||||
<p class="c_dark mb5 f14">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
|
||||
<% if @topics.any? %>
|
||||
<% @topics.each do |topic| %>
|
||||
<div class="talkmain_box" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;" id="topic<%= topic.id %>" nhname="container_board" mhname="container_board_reply">
|
||||
<%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
|
||||
<div class="talkmain_txt fl mt5">
|
||||
<div class="talkmain_txt fl mt5 f14">
|
||||
<% author = topic.author.to_s %>
|
||||
<div style="max-width:60px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;">
|
||||
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl ",:title=>author,
|
||||
:style=>'max-width:60px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %>
|
||||
<div style="max-width:120px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;">
|
||||
<%= link_to User.current.member_of_course?(@board.course) ? "#{topic.author.show_name}(#{topic.author.login})" : "#{topic.author}" , user_path(topic.author),
|
||||
:class =>"talkmain_name fl f14",:title=>author,
|
||||
:style=>'max-width:120px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %>
|
||||
</div>
|
||||
<p style="float:left;color:#ff5722;"> :</p>
|
||||
|
||||
<p class="talkmain_tit fl fb break_word" title="<%= h(topic.subject) %>" style="width:auto;float:left;max-width:415px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;"> <%= h(topic.subject) %></p>
|
||||
<p class="talkmain_tit fl fb break_word f14" title="<%= h(topic.subject) %>" style="width:auto;float:left;max-width:360px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;"> <%= h(topic.subject) %></p>
|
||||
<% if topic.course_editable_by?(User.current) %>
|
||||
<a href="javascript:void(0)" nhname="showbtn" style="color: #426e9a;float: right;
|
||||
margin-right: 10px;"><%= l(:button_edit) %></a>
|
||||
<% end %>
|
||||
|
||||
<%= link_to(
|
||||
l(:button_delete),
|
||||
{:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'talk_edit fr',
|
||||
:style => ' margin-right: 10px;'
|
||||
) if topic.destroyable_by?(User.current) %>
|
||||
<%= link_to(l(:button_delete), {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'talk_edit fr',
|
||||
:style => ' margin-right: 10px;') if topic.destroyable_by?(User.current) %>
|
||||
|
||||
<% if topic.sticky? %>
|
||||
<a href="javascript:void(0)" class="talk_up fr c_red" style="margin-right: 10px;"><%= l(:label_board_sticky)%></a>
|
||||
|
|
@ -101,7 +99,7 @@
|
|||
// }
|
||||
});
|
||||
</script>
|
||||
<div class="project_board_content break_word" id="content_<%=topic.id%>">
|
||||
<div class="project_board_content break_word f14" id="content_<%=topic.id%>">
|
||||
<div id="contentmessage<%=topic.id %>" class="upload_img">
|
||||
<%= topic.content.html_safe %>
|
||||
<!-- -->
|
||||
|
|
@ -122,7 +120,7 @@
|
|||
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
|
||||
|
||||
</div>
|
||||
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr" style="margin-right:10px;"><%= l(:button_reply) %></a>
|
||||
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr f14" style="margin-right:10px;"><%= l(:button_reply) %></a>
|
||||
|
||||
<div class="cl"></div>
|
||||
|
||||
|
|
@ -163,17 +161,17 @@
|
|||
<% replies_all.each do |message| %>
|
||||
<% replies_all_i=replies_all_i+1 %>
|
||||
<li nhname="reply_rec" style="display:<%= replies_all_i>2?'none':'' %>" id="topic<%=message.id%>">
|
||||
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
|
||||
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class => 'Msg_pic' %>
|
||||
<div class="Msg_txt">
|
||||
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
|
||||
<%= link_to User.current.member_of_course?(@board.course) ? "#{message.author.show_name}(#{message.author.login})" : "#{message.author}", user_path(message.author),:class => 'fl c_orange f14 ' %>
|
||||
<br/>
|
||||
<div class="fl break_word">
|
||||
<div class="fl break_word f14">
|
||||
<%= textAreailizable message,:content,:attachments => message.attachments %>
|
||||
<!-- -->
|
||||
</div>
|
||||
<input nhname="nh_content_val" value="<%= message.content %>" type="hidden"/>
|
||||
<br/><div class="cl"></div>
|
||||
<span class=" c_grey fl"><%= format_time(message.created_on) %></span>
|
||||
<span class=" c_grey fl f14"><%= format_time(message.created_on) %></span>
|
||||
<%= link_to(
|
||||
|
||||
l(:button_delete),
|
||||
|
|
@ -181,13 +179,13 @@
|
|||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete),
|
||||
:class => ' c_dblue fr'
|
||||
:class => ' c_dblue fr f14'
|
||||
) if message.course_destroyable_by?(User.current) %>
|
||||
<%= link_to(
|
||||
l(:button_reply),
|
||||
'javascript:;',
|
||||
:nhname =>'showbtn_child_reply',
|
||||
:class => ' c_dblue fr',
|
||||
:class => ' c_dblue fr f14',
|
||||
:style => 'margin-right: 10px;',
|
||||
'data-topic-id' =>message.id,
|
||||
:title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<%= error_messages_for @board %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p style="width:666;">
|
||||
<p style="width:666px;">
|
||||
<%= f.text_field :name, :required => true %>
|
||||
</p><!--by young-->
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<% if !User.current.logged? %>
|
||||
<div class="c_grey f14">
|
||||
<%= l(:label_user_login_project_board) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %>
|
||||
</div>
|
||||
<div class="c_grey f14">
|
||||
<%= l(:label_user_login_project_board) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<div class=" talklist_box" >
|
||||
|
|
@ -28,62 +28,59 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class=" talklist_box" >
|
||||
<p class="c_dark mb5">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
|
||||
<p class="c_dark mb5 f14">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
|
||||
<% if @topics.any? %>
|
||||
<% @topics.each do |topic| %>
|
||||
<div class="talkmain_box" id="topic<%= topic.id %>" nhname="container_board" mhname="container_board_reply" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;">
|
||||
<%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
|
||||
<div class="talkmain_txt fl mt5">
|
||||
<% author = topic.author.to_s %>
|
||||
<div style="max-width:60px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;">
|
||||
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl ",:title=>author,
|
||||
:style=>'max-width:60px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %>
|
||||
</div>
|
||||
<p style="float:left;color:#ff5722;"> :</p>
|
||||
<% @topics.each do |topic| %>
|
||||
<div class="talkmain_box" id="topic<%= topic.id %>" nhname="container_board" mhname="container_board_reply" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;">
|
||||
<%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
|
||||
<div class="talkmain_txt fl mt5 f14">
|
||||
<% author = topic.author.to_s %>
|
||||
<div style="max-width:80px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;">
|
||||
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl f14",:title=>author,
|
||||
:style=>'max-width:80px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %>
|
||||
</div>
|
||||
<p style="float:left;color:#ff5722;"> :</p>
|
||||
|
||||
<p class="talkmain_tit fl fb break_word" title="<%= h(topic.subject) %>" style="width:auto;float:left;max-width:415px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;"> <%= h(topic.subject) %></p>
|
||||
<div style="float:right;max-width:110px;">
|
||||
<% if topic.editable_by?(User.current) %>
|
||||
<a href="javascript:void(0)" nhname="showbtn" style="color: #426e9a;float: right;margin-right: 10px;"><%= l(:button_edit) %></a>
|
||||
<% end %>
|
||||
<%= link_to(
|
||||
l(:button_delete),
|
||||
{:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'talk_edit fr',
|
||||
:style => ' margin-right: 10px;'
|
||||
) if topic.destroyable_by?(User.current) %>
|
||||
<% if topic.sticky? %>
|
||||
<a href="javascript:void(0)" class="talk_up fr c_red" style="margin-right: 10px;"><%= l(:label_board_sticky)%></a>
|
||||
<% end %>
|
||||
<script>
|
||||
//$(function(){if($("#contentmessage<%#=topic.id %>").height()>182){$("#project_show_<%#= topic.id%>").show();}});
|
||||
//解决由于图片加载慢造成div高度不够 以至于展开按钮不显示的bug
|
||||
$(function(){
|
||||
function nh_show_btn(){
|
||||
if($("#project_show_<%= topic.id%>").is(':hidden')){
|
||||
if($("#contentmessage<%=topic.id %>").height()>182){
|
||||
$("#project_show_<%= topic.id%>").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
var div = $("#contentmessage<%=topic.id %>");
|
||||
var imgs = $('img',div);
|
||||
var lens = imgs.length;
|
||||
function nh_load_img_end(){
|
||||
nh_show_btn();
|
||||
<p class="talkmain_tit fl fb break_word f14" title="<%= h(topic.subject) %>" style="width:auto;float:left;max-width:390px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;"> <%= h(topic.subject) %></p>
|
||||
|
||||
<% if topic.editable_by?(User.current) %>
|
||||
<a href="javascript:void(0)" nhname="showbtn" style="color: #426e9a;float: right;margin-right: 10px;"><%= l(:button_edit) %></a>
|
||||
<% end %>
|
||||
<%= link_to(l(:button_delete), {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'talk_edit fr',
|
||||
:style => ' margin-right: 10px;') if topic.destroyable_by?(User.current) %>
|
||||
<% if topic.sticky? %>
|
||||
<a href="javascript:void(0)" class="talk_up fr c_red" style="margin-right: 10px;"><%= l(:label_board_sticky)%></a>
|
||||
<% end %>
|
||||
<script>
|
||||
//$(function(){if($("#contentmessage<%#=topic.id %>").height()>182){$("#project_show_<%#= topic.id%>").show();}});
|
||||
//解决由于图片加载慢造成div高度不够 以至于展开按钮不显示的bug
|
||||
$(function(){
|
||||
function nh_show_btn(){
|
||||
if($("#project_show_<%= topic.id%>").is(':hidden')){
|
||||
if($("#contentmessage<%=topic.id %>").height()>182){
|
||||
$("#project_show_<%= topic.id%>").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
var div = $("#contentmessage<%=topic.id %>");
|
||||
var imgs = $('img',div);
|
||||
var lens = imgs.length;
|
||||
function nh_load_img_end(){
|
||||
nh_show_btn();
|
||||
// lens--;
|
||||
// if(lens <= 0){
|
||||
// nh_show_btn();
|
||||
// }
|
||||
}
|
||||
if(lens > 0){
|
||||
$('img',div).load(function(){
|
||||
nh_load_img_end();
|
||||
});
|
||||
}
|
||||
nh_show_btn();
|
||||
}
|
||||
if(lens > 0){
|
||||
$('img',div).load(function(){
|
||||
nh_load_img_end();
|
||||
});
|
||||
}
|
||||
nh_show_btn();
|
||||
// if(lens <= 0){
|
||||
// nh_show_btn();
|
||||
// }else{
|
||||
|
|
@ -91,107 +88,100 @@
|
|||
// nh_load_img_end();
|
||||
// });
|
||||
// }
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="project_board_content break_word" id="content_<%=topic.id%>">
|
||||
<div id="contentmessage<%=topic.id %>" class="upload_img">
|
||||
<%= topic.content.html_safe %>
|
||||
<!-- -->
|
||||
</div>
|
||||
</div>
|
||||
<p style="display: none;" id="project_show_<%= topic.id%>">
|
||||
<a id="expend_more_information<%= topic.id%>" style="color: #0781b4;" href="javascript:void(0)" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a>
|
||||
<span class="g-arr-down">
|
||||
<img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" />
|
||||
</span>
|
||||
</p>
|
||||
<%= link_to_attachments_course topic, :author => false %>
|
||||
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
|
||||
</div>
|
||||
<% if User.current.logged? %>
|
||||
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr" style="margin-right:10px;"><%= l(:button_reply) %></a>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<div class="talk_new ml15 mb10" nhname='about_talk' id="about_newtalk<%=topic.id%>" style="display: none;border-top: 1px dashed #d9d9d9;padding-top:5px;margin-left:0px;padding-left:15px;">
|
||||
<ul>
|
||||
<%= render :partial => 'edit',locals: {:topic => topic} %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="talkWrapBox">
|
||||
<% reply = Message.new(:subject => "RE: #{topic.subject}")%>
|
||||
<% if !topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<div class="talkWrapMsg" nhname="about_talk_reply" style="display: none;">
|
||||
<em class="talkWrapArrow"></em>
|
||||
<div class="cl"></div>
|
||||
<div class="talkConIpt ml15 mb10" style="margin-left:30px;" id="reply<%= topic.id %>">
|
||||
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'},
|
||||
:html => {:nhname=>"form",:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
|
||||
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
|
||||
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
|
||||
<div style="padding-top:5px;" class="fr">
|
||||
<a href="javascript:void(0)" nhname="cancelbtn" class="grey_btn fr ml10" style=""><%= l(:button_cancel)%></a>
|
||||
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style=""><%= l(:button_submit)%></a>
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="project_board_content break_word f14" id="content_<%=topic.id%>">
|
||||
<div id="contentmessage<%=topic.id %>" class="upload_img">
|
||||
<%= topic.content.html_safe %>
|
||||
<!-- -->
|
||||
</div>
|
||||
</div>
|
||||
<p style="display: none;" id="project_show_<%= topic.id%>">
|
||||
<a id="expend_more_information<%= topic.id%>" style="color: #0781b4;" href="javascript:void(0)" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a>
|
||||
<span class="g-arr-down">
|
||||
<img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" />
|
||||
</span>
|
||||
</p>
|
||||
<%= link_to_attachments_course topic, :author => false %>
|
||||
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
|
||||
</div>
|
||||
<% if User.current.logged? %>
|
||||
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr f14" style="margin-right:10px;"><%= l(:button_reply) %></a>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<div class="talk_new ml15 mb10" nhname='about_talk' id="about_newtalk<%=topic.id%>" style="display: none;border-top: 1px dashed #d9d9d9;padding-top:5px;margin-left:0px;padding-left:15px;">
|
||||
<ul>
|
||||
<%= render :partial => 'edit',locals: {:topic => topic} %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="talkWrapBox">
|
||||
<% reply = Message.new(:subject => "RE: #{topic.subject}")%>
|
||||
<% if !topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<div class="talkWrapMsg" nhname="about_talk_reply" style="display: none;">
|
||||
<em class="talkWrapArrow"></em>
|
||||
<div class="cl"></div>
|
||||
<div class="talkConIpt ml15 mb10" style="margin-left:30px;" id="reply<%= topic.id %>">
|
||||
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'},
|
||||
:html => {:nhname=>"form",:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
|
||||
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
|
||||
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
|
||||
<div style="padding-top:5px;" class="fr">
|
||||
<a href="javascript:void(0)" nhname="cancelbtn" class="grey_btn fr ml10" style=""><%= l(:button_cancel)%></a>
|
||||
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style=""><%= l(:button_submit)%></a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<% replies_all = topic.children.includes(:author, :attachments, {:board => :project}).
|
||||
reorder("#{Message.table_name}.id desc").all %>
|
||||
<% unless replies_all.empty? %>
|
||||
<div class="talkWrapMsg" nhname="nh_reply_div" id="nh_reply_div_<%= topic.id %>">
|
||||
<ul>
|
||||
<% replies_all_i = 0 %>
|
||||
<% replies_all.each do |message| %>
|
||||
<% replies_all_i=replies_all_i+1 %>
|
||||
<li nhname="reply_rec" style="display:<%= replies_all_i>2?'none':'' %>">
|
||||
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
|
||||
<div class="Msg_txt">
|
||||
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
|
||||
<br/>
|
||||
<div class="fl break_word">
|
||||
<%= textAreailizable message,:content,:attachments => message.attachments %>
|
||||
<!-- -->
|
||||
</div>
|
||||
<input nhname="nh_content_val" type="hidden" value="<%= message.content %>"/>
|
||||
<br/><div class="cl"></div>
|
||||
<span class=" c_grey fl"><%= format_time(message.created_on) %></span>
|
||||
<%= link_to(
|
||||
|
||||
l(:button_delete),
|
||||
{:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete),
|
||||
:class => ' c_dblue fr'
|
||||
) if message.course_destroyable_by?(User.current) %>
|
||||
<%= link_to(
|
||||
l(:button_reply),
|
||||
'javascript:;',
|
||||
:nhname =>'showbtn_child_reply',
|
||||
:class => ' c_dblue fr',
|
||||
:style => 'margin-right: 10px;',
|
||||
:title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<% replies_all = topic.children.includes(:author, :attachments, {:board => :project}).reorder("#{Message.table_name}.id desc").all %>
|
||||
<% unless replies_all.empty? %>
|
||||
<div class="talkWrapMsg" nhname="nh_reply_div" id="nh_reply_div_<%= topic.id %>">
|
||||
<ul>
|
||||
<% replies_all_i = 0 %>
|
||||
<% replies_all.each do |message| %>
|
||||
<% replies_all_i=replies_all_i+1 %>
|
||||
<li nhname="reply_rec" style="display:<%= replies_all_i>2?'none':'' %>">
|
||||
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
|
||||
<div class="Msg_txt">
|
||||
<%= link_to_user_header message.author,false,:class => 'fl c_orange f14 ' %>
|
||||
<br/>
|
||||
<div class="fl break_word f14">
|
||||
<%= textAreailizable message,:content,:attachments => message.attachments %>
|
||||
<!-- -->
|
||||
</div>
|
||||
<input nhname="nh_content_val" type="hidden" value="<%= message.content %>"/>
|
||||
<br/><div class="cl"></div>
|
||||
<span class=" c_grey fl f14"><%= format_time(message.created_on) %></span>
|
||||
<%= link_to(l(:button_delete),{:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
|
||||
:method => :post,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete),
|
||||
:class => ' c_dblue fr f14') if message.course_destroyable_by?(User.current) %>
|
||||
<%= link_to(l(:button_reply), 'javascript:;',
|
||||
:nhname =>'showbtn_child_reply',
|
||||
:class => ' c_dblue fr f14',
|
||||
:style => 'margin-right: 10px;',
|
||||
:title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<%if topic.replies_count>2 %>
|
||||
<div class="talkWrapMsg">
|
||||
<a nhname="reply_ex_btn" data-count="<%= topic.replies_count %>" data-init="0" href="javascript:void(0)" class="ml258 c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<%if topic.replies_count>2 %>
|
||||
<div class="talkWrapMsg">
|
||||
<a nhname="reply_ex_btn" data-count="<%= topic.replies_count %>" data-init="0" href="javascript:void(0)" class="ml258 c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
|
|
@ -211,78 +201,78 @@
|
|||
<div style="display:none;"><a href="#" id="nhjump"></a></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$(".talkmain_box").each(function(){
|
||||
var target = $("li[nhname='reply_rec']",$(this));
|
||||
var btn = $("a[nhname='reply_ex_btn']",$(this));
|
||||
var jumpobj = $("div[nhname='nh_reply_div']",$(this));
|
||||
btn.click(function(){
|
||||
if($(this).data('init')=='0'){
|
||||
$(this).data('init',1);
|
||||
$(this).html('收起回复('+$(this).data('count')+')');
|
||||
target.show();
|
||||
}else{
|
||||
$(this).data('init',0);
|
||||
$(this).html('展开回复('+$(this).data('count')+')');
|
||||
target.hide();
|
||||
target.eq(0).show();
|
||||
target.eq(1).show();
|
||||
$("#nhjump").attr('href','#'+jumpobj.attr('id'));
|
||||
$("#nhjump")[0].click();
|
||||
}
|
||||
});
|
||||
});
|
||||
KindEditor.ready(function(K){
|
||||
$("div[nhname='container_board']").each(function(){
|
||||
var container = $(this);
|
||||
var about_talk = $("div[nhname='about_talk']",container);
|
||||
var params = ({
|
||||
kindutil:K,
|
||||
showbtn:$("a[nhname='showbtn']",container),
|
||||
about_talk:about_talk,
|
||||
inputsubject:$("input[nhname='inputsubject']",about_talk),
|
||||
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
|
||||
textarea:$("textarea[nhname='textarea']",about_talk),
|
||||
contentmsg:$("p[nhname='contentmsg']",about_talk),
|
||||
submitbtn:$("a[nhname='submitbtn']",about_talk),
|
||||
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
|
||||
form:$("form[nhname='form']",about_talk),
|
||||
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
|
||||
init_content_val:$("input[nhname='init_content_val']",about_talk)
|
||||
});
|
||||
nh_init_board(params);
|
||||
});
|
||||
$("div[mhname='container_board_reply']").each(function(){
|
||||
var container = $(this);
|
||||
var about_talk = $("div[nhname='about_talk_reply']",container);
|
||||
var params = {
|
||||
type:'reply',
|
||||
kindutil:K,
|
||||
showbtn:$("a[nhname='showbtn_reply']",container),
|
||||
showbtn_child:$("a[nhname='showbtn_child_reply']",container),
|
||||
about_talk:about_talk,
|
||||
inputsubject:$("input[nhname='inputsubject']",about_talk),
|
||||
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
|
||||
textarea:$("textarea[nhname='textarea']",about_talk),
|
||||
contentmsg:$("p[nhname='contentmsg']",about_talk),
|
||||
submitbtn:$("a[nhname='submitbtn']",about_talk),
|
||||
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
|
||||
form:$("form[nhname='form']",about_talk),
|
||||
quote_show:$("div[nhname='quote_show']",about_talk),
|
||||
quote_input:$("textarea[nhname='quote_input']",about_talk),
|
||||
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
|
||||
jumphref:$("#nhjump")
|
||||
};
|
||||
params.get_ref_str_call=function(btn){
|
||||
var div = btn.parent('div');
|
||||
var str = '<blockquote>'+$('a',div).filter(':first').html()+' 写到: <br/>'+$("input[nhname='nh_content_val']",div).val()+'<div class="cl"></div></blockquote>';
|
||||
return str;
|
||||
}
|
||||
nh_init_board(params);
|
||||
});
|
||||
<% if(!@flag.nil? && @flag=='true') %>
|
||||
if($("#new_topic_btn")!=undefined)$("#new_topic_btn").click();
|
||||
<% end %>
|
||||
});
|
||||
});
|
||||
$(function(){
|
||||
$(".talkmain_box").each(function(){
|
||||
var target = $("li[nhname='reply_rec']",$(this));
|
||||
var btn = $("a[nhname='reply_ex_btn']",$(this));
|
||||
var jumpobj = $("div[nhname='nh_reply_div']",$(this));
|
||||
btn.click(function(){
|
||||
if($(this).data('init')=='0'){
|
||||
$(this).data('init',1);
|
||||
$(this).html('收起回复('+$(this).data('count')+')');
|
||||
target.show();
|
||||
}else{
|
||||
$(this).data('init',0);
|
||||
$(this).html('展开回复('+$(this).data('count')+')');
|
||||
target.hide();
|
||||
target.eq(0).show();
|
||||
target.eq(1).show();
|
||||
$("#nhjump").attr('href','#'+jumpobj.attr('id'));
|
||||
$("#nhjump")[0].click();
|
||||
}
|
||||
});
|
||||
});
|
||||
KindEditor.ready(function(K){
|
||||
$("div[nhname='container_board']").each(function(){
|
||||
var container = $(this);
|
||||
var about_talk = $("div[nhname='about_talk']",container);
|
||||
var params = ({
|
||||
kindutil:K,
|
||||
showbtn:$("a[nhname='showbtn']",container),
|
||||
about_talk:about_talk,
|
||||
inputsubject:$("input[nhname='inputsubject']",about_talk),
|
||||
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
|
||||
textarea:$("textarea[nhname='textarea']",about_talk),
|
||||
contentmsg:$("p[nhname='contentmsg']",about_talk),
|
||||
submitbtn:$("a[nhname='submitbtn']",about_talk),
|
||||
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
|
||||
form:$("form[nhname='form']",about_talk),
|
||||
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
|
||||
init_content_val:$("input[nhname='init_content_val']",about_talk)
|
||||
});
|
||||
nh_init_board(params);
|
||||
});
|
||||
$("div[mhname='container_board_reply']").each(function(){
|
||||
var container = $(this);
|
||||
var about_talk = $("div[nhname='about_talk_reply']",container);
|
||||
var params = {
|
||||
type:'reply',
|
||||
kindutil:K,
|
||||
showbtn:$("a[nhname='showbtn_reply']",container),
|
||||
showbtn_child:$("a[nhname='showbtn_child_reply']",container),
|
||||
about_talk:about_talk,
|
||||
inputsubject:$("input[nhname='inputsubject']",about_talk),
|
||||
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
|
||||
textarea:$("textarea[nhname='textarea']",about_talk),
|
||||
contentmsg:$("p[nhname='contentmsg']",about_talk),
|
||||
submitbtn:$("a[nhname='submitbtn']",about_talk),
|
||||
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
|
||||
form:$("form[nhname='form']",about_talk),
|
||||
quote_show:$("div[nhname='quote_show']",about_talk),
|
||||
quote_input:$("textarea[nhname='quote_input']",about_talk),
|
||||
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
|
||||
jumphref:$("#nhjump")
|
||||
};
|
||||
params.get_ref_str_call=function(btn){
|
||||
var div = btn.parent('div');
|
||||
var str = '<blockquote>'+$('a',div).filter(':first').html()+' 写到: <br/>'+$("input[nhname='nh_content_val']",div).val()+'<div class="cl"></div></blockquote>';
|
||||
return str;
|
||||
}
|
||||
nh_init_board(params);
|
||||
});
|
||||
<% if(!@flag.nil? && @flag=='true') %>
|
||||
if($("#new_topic_btn")!=undefined)$("#new_topic_btn").click();
|
||||
<% end %>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
@ -1,12 +1,5 @@
|
|||
<style type="text/css">
|
||||
div.talk_new .ke-container{margin-left:2px;}
|
||||
/*div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
|
||||
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
|
||||
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
|
||||
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
|
||||
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
|
||||
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
|
||||
div.ke-toolbar .ke-outline{border:none;}*/
|
||||
.break_word {width:100%;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
|
@ -16,14 +9,14 @@
|
|||
for (var i=0; i<menuids.length; i++){
|
||||
var div = document.getElementById(menuids[i]);
|
||||
if(div == undefined)continue;
|
||||
var ultags=div.getElementsByTagName("ul")
|
||||
var ultags=div.getElementsByTagName("ul");
|
||||
for (var t=0; t<ultags.length; t++){
|
||||
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
|
||||
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle";
|
||||
ultags[t].parentNode.onmouseover=function(){
|
||||
this.getElementsByTagName("ul")[0].style.display="block"
|
||||
this.getElementsByTagName("ul")[0].style.display="block";
|
||||
}
|
||||
ultags[t].parentNode.onmouseout=function(){
|
||||
this.getElementsByTagName("ul")[0].style.display="none"
|
||||
this.getElementsByTagName("ul")[0].style.display="none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,46 +39,6 @@
|
|||
|
||||
<script type="text/javascript">//侧导航
|
||||
|
||||
//window.onload = function () {
|
||||
// var topic_id = getParam('topic_id');
|
||||
// document.getElementById(topic_id).focus();
|
||||
//}
|
||||
//
|
||||
//var getParam = function(name){
|
||||
// var search = document.location.search;
|
||||
// var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
|
||||
// var matcher = pattern.exec(search);
|
||||
// var items = null;
|
||||
// if(null != matcher){
|
||||
// try{
|
||||
// items = decodeURIComponent(decodeURIComponent(matcher[1]));
|
||||
// }catch(e){
|
||||
// try{
|
||||
// items = decodeURIComponent(matcher[1]);
|
||||
// }catch(e){
|
||||
// items = matcher[1];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return items;
|
||||
//};
|
||||
//
|
||||
//function show_newtalk()
|
||||
//{
|
||||
// $("#about_newtalk").toggle();
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
||||
//function show_newtalk1(id)
|
||||
//{
|
||||
// $(id).toggle();
|
||||
// $(id).focus();
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
if(params.subject!=undefined){
|
||||
|
|
|
|||
|
|
@ -50,9 +50,6 @@
|
|||
}
|
||||
}
|
||||
</script>
|
||||
<div class="add_frame_header" >
|
||||
<%= l(:bale_news_notice) %>
|
||||
</div>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<%= f.text_field :title,
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@
|
|||
|
||||
<!--gcm-->
|
||||
<p class="stats">
|
||||
<%= content_tag('span', link_to("#{@course_activity_count[@course.id]}", course_path(@course)), :class => "info") %>
|
||||
<%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>
|
||||
<%= content_tag('span', link_to("#{@course.course_activities.count}", course_path(@course)), :class => "info") %>
|
||||
<%= content_tag('span', l(:label_x_activity, :count => @course.course_activities.count)) %>
|
||||
</p>
|
||||
<!--gcm-->
|
||||
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||
<% if journals.size > 0 %>
|
||||
<% for journal in journals %>
|
||||
<div class="ping_C" id='word_li_<%= journal.id.to_s %>'>
|
||||
<div class="ping_dispic">
|
||||
<%= link_to image_tag(url_to_avatar(journal.user),:width => '46',:height => '46'), user_path(journal.user) %>
|
||||
</div>
|
||||
<div class="ping_discon upload_img" style="width: 610px;">
|
||||
<div class="ping_distop">
|
||||
<!-- <a style=" font-weight:bold; color:#15bccf; margin-right:30px; background:none;" target="_blank" href="#">gugu01</a> -->
|
||||
<% if journals.size > 0 %>
|
||||
<% for journal in journals %>
|
||||
<div class="ping_C" id='word_li_<%= journal.id.to_s %>'>
|
||||
<div class="ping_dispic">
|
||||
<%= link_to image_tag(url_to_avatar(journal.user),:width => '46',:height => '46'), user_path(journal.user) %>
|
||||
</div>
|
||||
<div class="ping_discon upload_img" style="width: 610px;">
|
||||
<div class="ping_distop f14">
|
||||
<!-- <a style=" font-weight:bold; color:#15bccf; margin-right:30px; background:none;" target="_blank" href="#">gugu01</a> -->
|
||||
<span>
|
||||
<%= link_to "#{journal.user.show_name}(#{journal.user.login})", user_path(journal.user),:class => 'c_blue fb fl mb10', :target => "_blank"%>
|
||||
<%= link_to "#{journal.user.show_name}(#{journal.user.login})", user_path(journal.user),:class => 'c_blue fb fl mb10 f14', :target => "_blank"%>
|
||||
</span>
|
||||
<span class="c_grey fr">
|
||||
<span class="c_grey fr f14">
|
||||
<%= format_time(journal.created_on) %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
<%= journal.notes.html_safe %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="ping_disfoot">
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
|
||||
<% if journal.user == User.current|| User.current.admin? || (@course && User.current.allowed_to?(:as_teacher,@course)) %>
|
||||
<%= link_to(l(:label_bid_respond_delete),
|
||||
{:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => @user},
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete',
|
||||
:class => "delete", :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
<% if reply_allow %>
|
||||
<%#= link_to l(:label_bid_respond_quote),'',
|
||||
{:focus => 'project_respond',:nhname=>"reply_btn", :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %>
|
||||
<%= link_to l(:label_bid_respond_quote),'javascript:;',{:nhname=>"reply_btn"} %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
<% if reply_allow %>
|
||||
<div id='<%= ids %>' class="respond-form">
|
||||
<%= render :partial => 'words/new_respond_course', :locals => {:journal => journal, :m_reply_id => journal,:show_name => true} %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
||||
<%= render :partial => "words/journal_reply", :locals => {:journal => journal, :show_name => true, :allow_delete => @course && User.current.allowed_to?(:as_teacher,@course)} %>
|
||||
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
<%= journal.notes.html_safe %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="ping_disfoot f14">
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
|
||||
<% if journal.user == User.current|| User.current.admin? || (@course && User.current.allowed_to?(:as_teacher,@course)) %>
|
||||
<%= link_to(l(:label_bid_respond_delete),
|
||||
{:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => @user},
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete',
|
||||
:class => "delete", :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
<% if reply_allow %>
|
||||
<%#= link_to l(:label_bid_respond_quote),'',
|
||||
{:focus => 'project_respond',:nhname=>"reply_btn", :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %>
|
||||
<%= link_to l(:label_bid_respond_quote),'javascript:;',{:nhname=>"reply_btn"} %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
<% if reply_allow %>
|
||||
<div id='<%= ids %>' class="respond-form">
|
||||
<%= render :partial => 'words/new_respond_course', :locals => {:journal => journal, :m_reply_id => journal,:show_name => true} %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
||||
<%= render :partial => "words/journal_reply", :locals => {:journal => journal, :show_name => true, :allow_delete => @course && User.current.allowed_to?(:as_teacher,@course)} %>
|
||||
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<img src="/images/pic_del.gif" width="11" height="12" alt="删除班级" title="删除该班级" />
|
||||
</a>
|
||||
<% end%>
|
||||
<a href="javascript:void(0)" class="f_l" style="padding-left: 5px;" onclick="$('#group_name_<%= group.id %>').val('');$('#edit_group_<%= group.id %>').slideToggle();">
|
||||
<a href="javascript:void(0)" class="f_l" style="padding-left: 5px;" onclick="$('#group_name_<%= group.id %>').val('<%= group.name%>');$('#edit_group_<%= group.id %>').slideToggle();$('#new_group_name').hide();">
|
||||
<img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" />
|
||||
</a>
|
||||
<% end %>
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
<% if @canShowCode%>
|
||||
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, :id => 'update_group_'+group.id.to_s) do %>
|
||||
<span id="edit_group_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
|
||||
<input type="text" id="group_name_<%= group.id%>" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
|
||||
<input type="text" id="group_name_<%= group.id%>" name="group_name" size="20" class="isTxt w90 f_l" maxlength="20" />
|
||||
<input type="button" class="submit f_l" onclick="edit_group('group_name_<%= group.id%>','<%= valid_ajax_course_path%>','<%= @course.id%>','<%= group.id%>');"/>
|
||||
</span>
|
||||
<% end %>
|
||||
|
|
@ -42,12 +42,12 @@
|
|||
|
||||
<% if @canShowCode %>
|
||||
<li style="margin-left:15px;margin-top: 2px;">
|
||||
<a href="javascript:void(0)" class="st_add f_l" onclick="$('#group_name').value='';$('#new_group_name').slideToggle();">+添加分班</a>
|
||||
<a href="javascript:void(0)" class="st_add f_l" onclick="$('#group_name').value='';$('#new_group_name').slideToggle();$('#edit_group_36').hide();">+添加分班</a>
|
||||
</li>
|
||||
<li >
|
||||
<span id="new_group_name" style="display:none; vertical-align: middle;" class="ml10 f_l">
|
||||
<%= form_tag( addgroups_course_path(@course), method: 'get',:remote=>true,:id => 'add_group_name') do %>
|
||||
<input type="text" id="group_name" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
|
||||
<input type="text" id="group_name" name="group_name" size="20" class="isTxt w90 f_l" maxlength="20" />
|
||||
<input type="button" class="submit f_l" onclick="add_group('<%= valid_ajax_course_path%>','<%= @course.id%>');"/>
|
||||
<% end %>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
:member_id => member.id,
|
||||
:remote => true},
|
||||
:class => 'ml258 c_red' %>
|
||||
<span class="ml65 c_grey"><%= format_date(member.created_on)%></span>
|
||||
<span class="fr mr15 c_grey"><%= format_date(member.created_on)%></span>
|
||||
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
|||
|
|
@ -4,13 +4,16 @@
|
|||
<% if @state %>
|
||||
<% if @state == 0 %>
|
||||
alert("加入成功");
|
||||
hideModal($("#popbox"));
|
||||
hideModal($("#popbox02"));
|
||||
$("#try_join_course_link").replaceWith("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
<% elsif @state == 1 %>
|
||||
alert("密码错误");
|
||||
<% elsif @state == 2 %>
|
||||
alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)");
|
||||
<% elsif @state == 3 %>
|
||||
alert("您已经加入了课程");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
<% elsif @state == 4 %>
|
||||
alert("您加入的课程不存在");
|
||||
<% elsif @state == 5 %>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<li ><span class="c_blue02 w280">作业名称</span><span class="c_blue02 w70">得分</span></li>
|
||||
<% @member_score.homework_common_list.each do |homework_common| %>
|
||||
<li>
|
||||
<span class="c_grey02 w280">
|
||||
<span class="c_grey02 w280 hiddent">
|
||||
<%= homework_common.name %>
|
||||
</span>
|
||||
<span class="c_red w70">
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
<li><span class="c_blue03 w280">作业积分(平均分)</span><span class="c_red w70"><%= @member_score.student_work_score_avg %></span></li>
|
||||
<li><span class="c_blue03 w280">作业积分(总分)</span><span class="c_red w70"><%= @member_score.student_work_score_sum %></span></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<% if @save_flag %>
|
||||
$('#finish_course_<%=@course.id%>').replaceWith("<%= escape_javascript(set_course_time(@course_prefs))%>");
|
||||
$('#finish_course_<%=@course.id%>').replaceWith("<%= escape_javascript(set_course_time(@course_prefs))%>");
|
||||
var html = "<%= escape_javascript( render( :partial => 'users/course_form', :locals => {:item => @course_prefs} ) )%>";
|
||||
$('#nh_course_<%=@course.id%>').replaceWith(html);
|
||||
// alert("关闭成功");
|
||||
<% else %>
|
||||
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
||||
<% end %>
|
||||
|
||||
|
||||
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
||||
<% end %>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue