Merge branch 'szzh' into gitlab
Conflicts: app/controllers/repositories_controller.rb db/schema.rb
This commit is contained in:
commit
098fd6c276
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,返回该学校课程列表'
|
||||
|
@ -247,7 +250,7 @@ module Mobile
|
|||
end
|
||||
get "course_dynamic/:id" do
|
||||
cs = CoursesService.new
|
||||
count = cs.course_dynamic(params,current_user)
|
||||
count = cs.all_course_dynamics(params,current_user)
|
||||
present :data, count, with: Mobile::Entities::CourseDynamic
|
||||
present :status, 0
|
||||
end
|
||||
|
@ -311,6 +314,83 @@ module Mobile
|
|||
present :data,news,with:Mobile::Entities::News
|
||||
present :status,0
|
||||
end
|
||||
|
||||
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[:user_list],with:Mobile::Entities::User
|
||||
present :maxSize,news[:max_size]
|
||||
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'
|
||||
optional :page,type:Integer,desc:'页码'
|
||||
end
|
||||
get ':course_id/student_works_list' do
|
||||
cs = CoursesService.new
|
||||
student_works = cs.student_work_list params,current_user
|
||||
present :data,student_works,with:Mobile::Entities::StudentWork
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '讨论区信息'
|
||||
params do
|
||||
requires :token,type:String
|
||||
requires :course_id,type:Integer,desc:'课程id'
|
||||
optional :page,type:Integer,desc:'页码'
|
||||
end
|
||||
get ':course_id/board_message_list' do
|
||||
cs = CoursesService.new
|
||||
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
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class Attachment < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.attachment_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::Attachment)
|
||||
if f.respond_to?(field)
|
||||
f.send(field)
|
||||
if field == :created_on
|
||||
format_time(f.send(field))
|
||||
else
|
||||
f.send(field)
|
||||
end
|
||||
else
|
||||
#case field
|
||||
# when ""
|
||||
#end
|
||||
case field
|
||||
when :file_dir
|
||||
"attachments/download/" << f.send(:id).to_s << '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -21,6 +27,8 @@ module Mobile
|
|||
attachment_expose :description
|
||||
attachment_expose :downloads
|
||||
attachment_expose :quotes
|
||||
attachment_expose :created_on
|
||||
attachment_expose :file_dir
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,6 +6,38 @@ module Mobile
|
|||
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
|
||||
c[field] if (c.is_a?(Hash) && c.key?(field))
|
||||
end
|
||||
|
@ -21,6 +53,74 @@ module Mobile
|
|||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
expose :active_students,using:Mobile::Entities::User do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 7
|
||||
obj = d[:active_students]
|
||||
end
|
||||
end
|
||||
obj
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +1,10 @@
|
|||
# 这个模块由于作业模块的改变,里边的注释以及属性不可信
|
||||
module Mobile
|
||||
module Entities
|
||||
class Homework < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.homework_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
|
@ -14,7 +17,27 @@ module Mobile
|
|||
if f.respond_to?(field)
|
||||
f.send(field)
|
||||
else
|
||||
|
||||
case field
|
||||
when :homework_name
|
||||
f.send(:name)
|
||||
when :homework_notsubmit_num
|
||||
f.course.members.count - f.student_works.count
|
||||
when :homework_submit_num
|
||||
f.student_works.count
|
||||
when :homework_status_student
|
||||
get_homework_status f
|
||||
when :homework_times
|
||||
f.course.homework_commons.index(f) + 1
|
||||
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
|
||||
end
|
||||
|
@ -60,6 +83,17 @@ module Mobile
|
|||
f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments)
|
||||
end
|
||||
|
||||
homework_expose :homework_submit_num
|
||||
homework_expose :homework_notsubmit_num
|
||||
|
||||
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
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class Message < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.message_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::Message)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_on
|
||||
format_time( u.send(f))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
else
|
||||
# case f
|
||||
# when :xx
|
||||
# #
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::Message)
|
||||
c.author
|
||||
end
|
||||
end
|
||||
message_expose :board_id
|
||||
message_expose :subject
|
||||
message_expose :content
|
||||
message_expose :replies_count
|
||||
message_expose :created_on
|
||||
message_expose :id
|
||||
expose :message_children,using:Mobile::Entities::Message do |c,opt|
|
||||
if c.is_a? (::Message)
|
||||
c.children
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,6 +6,12 @@ module Mobile
|
|||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::News)
|
||||
if field == :created_on
|
||||
format_time(f.send(field)) if f.respond_to?(field)
|
||||
else
|
||||
f.send(field) if f.respond_to?(field)
|
||||
end
|
||||
elsif f.is_a?(Hash) && !f.key?(field)
|
||||
n = f[:news]
|
||||
comments = f[:comments]
|
||||
|
@ -26,13 +32,20 @@ module Mobile
|
|||
news_expose :title
|
||||
|
||||
expose :author,using: Mobile::Entities::User do |f, opt|
|
||||
n = f[:news]
|
||||
n.author if n.respond_to?(:author)
|
||||
obj = nil
|
||||
if f.is_a?(::News) && f.respond_to?(:author)
|
||||
obj = f.send(:author)
|
||||
elsif f.is_a?(Hash) && f.key?(:author)
|
||||
obj = f[:author]
|
||||
end
|
||||
obj
|
||||
end
|
||||
#作者id
|
||||
news_expose :author_id
|
||||
#作者名
|
||||
news_expose :author_name
|
||||
#作者头像url
|
||||
news_expose :author_img_url
|
||||
#新闻内容
|
||||
news_expose :description
|
||||
#发布时间
|
||||
|
@ -43,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
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class StudentWork < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.student_work_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::StudentWork)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time(u.send(:created_at))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
|
||||
else
|
||||
case f
|
||||
when :student_id
|
||||
u.user.user_extensions.student_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::StudentWork)
|
||||
c.user
|
||||
end
|
||||
end
|
||||
student_work_expose :student_id
|
||||
student_work_expose :id
|
||||
student_work_expose :name
|
||||
student_work_expose :description
|
||||
student_work_expose :final_score
|
||||
student_work_expose :teacher_score
|
||||
student_work_expose :student_score
|
||||
student_work_expose :teacher_asistant_score
|
||||
student_work_expose :created_at
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,6 +22,8 @@ module Mobile
|
|||
get_user_location u unless u.user_extensions.nil?
|
||||
when :brief_introduction
|
||||
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.brief_introduction
|
||||
when :student_num
|
||||
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.student_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -47,6 +49,12 @@ module Mobile
|
|||
user_expose :location
|
||||
#签名
|
||||
user_expose :brief_introduction
|
||||
#总成绩
|
||||
user_expose :score
|
||||
#学号
|
||||
user_expose :student_num
|
||||
# 活跃值
|
||||
user_expose :active_count
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class ActivityNotifysController < ApplicationController
|
|||
# accept_rss_auth :index, :show
|
||||
|
||||
helper :activities
|
||||
helper :attachments
|
||||
def index
|
||||
query = nil
|
||||
if @course
|
||||
|
@ -21,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)
|
||||
|
|
|
@ -34,13 +34,21 @@ class AdminController < ApplicationController
|
|||
def projects
|
||||
@status = params[:status] || 1
|
||||
|
||||
scope = Project.status(@status).order('lft')
|
||||
scope = Project.status(@status).order('id asc')
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@projects = scope.where(project_type: Project::ProjectType_project).all
|
||||
|
||||
render :action => "projects", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def courses
|
||||
@name = params[:name]
|
||||
@courses = Course.like(@name)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def users
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
|
|
@ -388,7 +388,7 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
rescue NoMethodError
|
||||
@save_flag = false
|
||||
@save_message = [] << l(:label_course_empty_select)
|
||||
@save_message = [] << l(:label_project_empty_select)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
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
|
||||
|
|
|
@ -34,6 +34,20 @@ class CommentsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
if( @comment.id && @news.course )
|
||||
if(@news.author_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
notify.activity_container_id = @news.course.id
|
||||
notify.activity_container_type = 'Course'
|
||||
notify.activity_id = @comment.id
|
||||
notify.activity_type = 'Comment'
|
||||
notify.notify_to = @news.author_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
end
|
||||
|
||||
|
|
|
@ -298,7 +298,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 +368,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'
|
||||
|
@ -443,26 +443,19 @@ class CoursesController < ApplicationController
|
|||
def create
|
||||
cs = CoursesService.new
|
||||
@course = cs.create_course(params,User.current)[:course]
|
||||
if @course.new_record?
|
||||
if @course
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'new_base' } #Added by young
|
||||
format.api { render_validation_errors(@course) }
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
format.html {redirect_to settings_course_url(@course, :course_type => 1)}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
# render :layout => 'base_courses'
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if params[:continue]
|
||||
redirect_to new_course_url(attrs, :course => '0')
|
||||
elsif params[:course_continue]
|
||||
redirect_to new_course_url(:course => '1')
|
||||
else
|
||||
redirect_to settings_course_url(@course, :course_type => 1)
|
||||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||
end
|
||||
flash[:notice] = l(:notice_create_failed)
|
||||
# @course = Course.new
|
||||
format.html { redirect_to new_course_path } #Added by young
|
||||
format.api { render_validation_errors(@course) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -532,7 +525,7 @@ class CoursesController < ApplicationController
|
|||
@trackers = Tracker.sorted.all
|
||||
@course = Course.new
|
||||
@course.safe_attributes = params[:course]
|
||||
month = Time.now.month
|
||||
# month = Time.now.month
|
||||
render :layout => 'new_base'
|
||||
end
|
||||
|
||||
|
@ -845,7 +838,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}
|
||||
|
@ -857,7 +850,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}
|
||||
|
|
|
@ -37,7 +37,7 @@ class FilesController < ApplicationController
|
|||
obj.each do |container|
|
||||
@attachments += container.attachments
|
||||
end
|
||||
@all_attachments = visable_attachemnts(@attachments)
|
||||
@all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
|
||||
@limit = 10
|
||||
@feedback_count = @all_attachments.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
|
|
|
@ -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,6 @@
|
|||
#added by baiyu
|
||||
class GitUsageController < ApplicationController
|
||||
layout "project_base"
|
||||
layout "new_base"
|
||||
def ch_usage
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
class HomeworkCommonController < ApplicationController
|
||||
require 'net/http'
|
||||
require 'json'
|
||||
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 +18,59 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@homework_type = "1"
|
||||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 0
|
||||
@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 = 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
|
||||
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 = 0
|
||||
@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 = 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
|
||||
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,15 +91,57 @@ 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[: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.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
|
||||
respond_to do |format|
|
||||
|
@ -90,22 +173,77 @@ 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.late_penalty = params[:late_penalty]
|
||||
@homework.user_id = User.current.id
|
||||
@homework.course_id = @course.id
|
||||
@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]
|
||||
student_work.save
|
||||
end
|
||||
@homework.late_penalty = params[:late_penalty]
|
||||
end
|
||||
# @homework.course_id = @course.id
|
||||
|
||||
#匿评作业相关属性
|
||||
@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]
|
||||
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
@homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
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]
|
||||
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
unless @homework_detail_manual.absence_penalty == params[:absence_penalty]
|
||||
if @homework_detail_manual.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
|
||||
@homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
end
|
||||
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 if @homework_detail_manual
|
||||
end
|
||||
|
||||
if @homework.homework_type == 2 && @homework_detail_programing #编程作业
|
||||
@homework_detail_programing.language = "C++"
|
||||
@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[: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]
|
||||
else #不存在的测试,增加
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.homework_common = @homework
|
||||
end
|
||||
homework_test.save
|
||||
end
|
||||
end
|
||||
end
|
||||
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)
|
||||
|
@ -135,6 +273,7 @@ class HomeworkCommonController < ApplicationController
|
|||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
def start_anonymous_comment
|
||||
@statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
|
||||
@statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if @homework_detail_manual.comment_status == 1
|
||||
student_works = @homework.student_works
|
||||
if student_works && student_works.size >=2
|
||||
|
@ -161,6 +300,14 @@ class HomeworkCommonController < ApplicationController
|
|||
#关闭匿评
|
||||
def stop_anonymous_comment
|
||||
@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
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -195,6 +342,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
|
||||
|
@ -206,7 +354,7 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
#当前用户是不是课程的成员
|
||||
def member_of_course
|
||||
render_403 unless User.current.member_of_course?(@course) || User.current.admin?
|
||||
render_403 unless @course.is_public || User.current.member_of_course?(@course) || User.current.admin?
|
||||
end
|
||||
|
||||
def get_assigned_homeworks(student_works, n, index)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class IssueCategoriesController < ApplicationController
|
||||
layout "project_base"
|
||||
layout "base_projects"
|
||||
menu_item :settings
|
||||
model_object IssueCategory
|
||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||
|
|
|
@ -74,6 +74,7 @@ class JournalsController < ApplicationController
|
|||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
# @content = "<blockquote style='word-break: break-all;word-wrap: break-word;'>" << @content
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -73,8 +73,14 @@ class NewsController < ApplicationController
|
|||
@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")
|
||||
if params[:subject].nil?
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
else
|
||||
scope_order = scope.where("news.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 +89,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,6 +148,21 @@ class NewsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
|
||||
teachers = searchTeacherAndAssistant(@course)
|
||||
for teacher in teachers
|
||||
if(teacher.user_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
notify.activity_container_id = @course.id
|
||||
notify.activity_container_type = 'Course'
|
||||
notify.activity_id = @news.id
|
||||
notify.activity_type = 'News'
|
||||
notify.notify_to = teacher.user_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
# <20><><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 'project_base'
|
||||
# layout 'base_projects'
|
||||
before_filter :require_admin, :except => [:index]
|
||||
|
||||
def index
|
||||
|
|
|
@ -23,7 +23,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
|
||||
|
@ -393,7 +393,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
|
||||
|
|
|
@ -361,6 +361,37 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# dts测试工具
|
||||
def dts_dep
|
||||
render_403 unless User.current.admin?
|
||||
@dts = Dts.all
|
||||
end
|
||||
|
||||
# dts云部署
|
||||
def yun_dep
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 软件知识库
|
||||
def soft_knowledge
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 在线开发平台
|
||||
def online_dev
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 软件资源库
|
||||
def soft_file
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 软件服务
|
||||
def soft_service
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
#发送邮件邀请新用户
|
||||
def invite_members_by_mail
|
||||
if User.current.member_of?(@project) || User.current.admin?
|
||||
|
@ -438,9 +469,9 @@ class ProjectsController < ApplicationController
|
|||
case params[:role]
|
||||
when '1'
|
||||
@subPage_title = l :label_teacher_list
|
||||
@members = searchTeacherAndAssistant(@project)
|
||||
@members = searchTeacherAndAssistant(@project)
|
||||
when '2'
|
||||
@subPage_title = l :label_student_list
|
||||
@subPage_title = l :label_student_list
|
||||
@members = searchStudent(@project)
|
||||
else
|
||||
@subPage_title = ''
|
||||
|
@ -578,7 +609,7 @@ class ProjectsController < ApplicationController
|
|||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
render :layout => "project_base"
|
||||
render :layout => "base_projects"
|
||||
end
|
||||
# hide project in layout
|
||||
@project = nil
|
||||
|
@ -586,7 +617,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def show_projects_score
|
||||
respond_to do |format|
|
||||
format.html { render :layout => "project_base"}
|
||||
format.html { render :layout => "base_projects"}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
@ -674,10 +705,10 @@ class ProjectsController < ApplicationController
|
|||
private
|
||||
|
||||
def memberAccess
|
||||
# 是课程,则判断当前用户是否参加了课程
|
||||
# return 0 if @project.project_type == Project::ProjectType_project
|
||||
# currentUser = User.current
|
||||
render_403 unless User.current.member_of?(@project)
|
||||
# 如果是私有项目,项目成员不对外公开,公开项目成员列表对外公开。
|
||||
unless @project.is_public?
|
||||
render_403 unless User.current.member_of?(@project)
|
||||
end
|
||||
end
|
||||
|
||||
def toggleCourse
|
||||
|
|
|
@ -548,7 +548,7 @@ 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
|
||||
)
|
||||
|
@ -569,7 +569,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}
|
||||
|
@ -591,7 +591,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
|
||||
|
|
|
@ -72,6 +72,22 @@ class StoresController < ApplicationController
|
|||
l(:label_borad_project), #l(:label_contest_innovate),
|
||||
l(:label_forum) ]
|
||||
end
|
||||
|
||||
#缺失文件列表
|
||||
def lost_file
|
||||
attachments = []
|
||||
Attachment.where("container_id is not null and container_type is not null and container_type <> 'Bid' and container_type <> 'HomeworkAttach'").each do |attachment|
|
||||
unless File.exist?(attachment.diskfile)
|
||||
attachments << attachment
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(homework_to_xls(attachments), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{l(:label_file_lost_list)}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
@ -117,4 +133,27 @@ class StoresController < ApplicationController
|
|||
else
|
||||
end
|
||||
end
|
||||
|
||||
#作品列表转换为excel
|
||||
def homework_to_xls attachments
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
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(["文件ID","文件名","硬盘路径","上传时间","是否公开","所属对象","所属对象Id"])
|
||||
count_row = 1
|
||||
attachments.each do |attachment|
|
||||
sheet1[count_row,0] = attachment.id
|
||||
sheet1[count_row,1] = attachment.filename
|
||||
sheet1[count_row,2] = attachment.diskfile
|
||||
sheet1[count_row,3] = format_time(attachment.created_on)
|
||||
sheet1[count_row,4] = (attachment.is_public == 1 || attachment.is_public) ? "是" :"否"
|
||||
sheet1[count_row,5] = attachment.container_type
|
||||
sheet1[count_row,6] = attachment.container_id
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,42 +2,85 @@ class StudentWorkController < ApplicationController
|
|||
layout "base_courses"
|
||||
include StudentWorkHelper
|
||||
require 'bigdecimal'
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty]
|
||||
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] || "final_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
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin?
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
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
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
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.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.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.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")
|
||||
|
@ -72,8 +115,30 @@ class StudentWorkController < ApplicationController
|
|||
stundet_work.homework_common_id = @homework.id
|
||||
stundet_work.user_id = User.current.id
|
||||
stundet_work.save_attachments(params[:attachments])
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
stundet_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
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)
|
||||
|
@ -92,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
|
||||
|
||||
|
@ -128,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)
|
||||
|
@ -147,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
|
||||
|
@ -154,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
|
||||
|
||||
|
@ -173,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
|
||||
|
@ -241,25 +324,101 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#评价列表显示
|
||||
#缺评列表显示
|
||||
def student_work_absence_penalty
|
||||
render_403 unless User.current.allowed_to?(:as_teacher,@course)
|
||||
order = params[:order] || "desc"
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM(
|
||||
if @homework.student_works.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM(
|
||||
SELECT * ,
|
||||
(SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
|
||||
(SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
|
||||
FROM `student_works`
|
||||
WHERE homework_common_id = #{@homework.id}
|
||||
) AS table_1
|
||||
ORDER BY absence #{order}")
|
||||
) AS table_1
|
||||
ORDER BY absence #{order}")
|
||||
end
|
||||
@order = order == "desc" ? "asc" : "desc"
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#导出缺评列表
|
||||
def absence_penalty_list
|
||||
if @homework.student_works.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@stundet_works = StudentWork.find_by_sql("SELECT * FROM (SELECT *,(all_count - has_count) AS absence FROM(
|
||||
SELECT * ,
|
||||
(SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
|
||||
(SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
|
||||
FROM `student_works`
|
||||
WHERE homework_common_id = #{@homework.id}
|
||||
) AS table_1) AS table_2
|
||||
where absence > 0 order by absence")
|
||||
end
|
||||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_absence_list)}.xls")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
#导出匿评列表
|
||||
def evaluation_list
|
||||
respond_to do |format|
|
||||
format.xls {
|
||||
send_data(evaluation_list_xls(@homework.student_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_evaluation_list)}.xls")
|
||||
}
|
||||
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_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first
|
||||
if 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
|
||||
|
@ -280,13 +439,17 @@ class StudentWorkController < ApplicationController
|
|||
#是不是当前课程的成员
|
||||
#当前课程成员才可以看到作品列表
|
||||
def member_of_course
|
||||
render_403 unless User.current.member_of_course? @course || User.current.admin?
|
||||
render_403 unless User.current.member_of_course?(@course) || User.current.admin?
|
||||
end
|
||||
|
||||
#判断是不是当前作品的提交者
|
||||
#提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
|
||||
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
|
||||
render_403 unless User.current.allowed_to?(:as_teacher,@course)
|
||||
end
|
||||
|
||||
#根据条件过滤作业结果
|
||||
|
@ -298,6 +461,7 @@ class StudentWorkController < ApplicationController
|
|||
select_homework
|
||||
end
|
||||
|
||||
#作品列表转换为excel
|
||||
def homework_to_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
|
@ -317,11 +481,62 @@ class StudentWorkController < ApplicationController
|
|||
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,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
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
|
||||
#缺评列表转换为excel
|
||||
def absence_penalty_list_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
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_student_id),l(:excel_nickname),l(:excel_user_name),l(:lable_all_penalty),l(:lable_has_penalty),l(:lable_absence_penalty)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,1] = homework.user.login
|
||||
sheet1[count_row,2] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,3] = homework.all_count
|
||||
sheet1[count_row,4] = homework.has_count
|
||||
sheet1[count_row,5] = homework.absence
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
|
||||
#匿评列表转换为excel
|
||||
def evaluation_list_xls items
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
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(:label_work_name),l(:label_work_id),l(:label_work_autor),l(:label_evaluation_id),l(:label_evaluation_name),
|
||||
l(:label_evaluation_score),l(:label_evaluation_common),l(:label_evaluation_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
homework.student_works_scores.where(:reviewer_role => 3).each do |score|
|
||||
sheet1[count_row,0] = homework.name
|
||||
sheet1[count_row,1] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,2] = homework.user.show_name
|
||||
sheet1[count_row,3] = score.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = score.user.show_name
|
||||
sheet1[count_row,5] = score.score
|
||||
sheet1[count_row,6] = score.comment
|
||||
sheet1[count_row,7] = format_time(score.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
end
|
|
@ -26,10 +26,10 @@ 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
|
||||
|
||||
|
||||
|
||||
|
||||
#Ended by young
|
||||
|
||||
# edit
|
||||
|
@ -39,23 +39,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]
|
||||
#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]
|
||||
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 +81,9 @@ class UsersController < ApplicationController
|
|||
|
||||
# fq
|
||||
helper :words
|
||||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
|
||||
def refresh_changests
|
||||
if !(@user.nil?) && !(@user.memberships.nil?)
|
||||
|
@ -104,27 +112,41 @@ 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
|
||||
|
||||
#add by huang
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
render_404
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
#end
|
||||
# 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
|
||||
|
||||
limit = 10;
|
||||
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(params[:status] == '1')
|
||||
query = query.where("#{Project.table_name}.user_id = ?",@user.id);
|
||||
elsif(params[:status] == '2')
|
||||
query = query.where("#{Project.table_name}.user_id <> ?",@user.id);
|
||||
end
|
||||
@obj_count = query.count();
|
||||
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Project.table_name}.updated_on desc,#{Project.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@params = params
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.html{render :layout=>'base_users_new'}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
@ -161,21 +183,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 +234,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,48 +255,63 @@ 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?)
|
||||
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))
|
||||
limit = 10;
|
||||
query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
|
||||
query = query.where("m.user_id = ?",@user.id)
|
||||
if(params[:status] == '1')
|
||||
query = query.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now);
|
||||
elsif(params[:status] == '2')
|
||||
query = query.where("endup_time < ?",Time.now);
|
||||
end
|
||||
@obj_count = query.count();
|
||||
|
||||
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
|
||||
}
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Course.table_name}.updated_at desc,#{Course.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@params = params
|
||||
render :layout=>'base_users_new'
|
||||
|
||||
# if User.current == @user || User.current.admin?
|
||||
# membership = @user.coursememberships.all
|
||||
# else
|
||||
# membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
# 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
|
||||
# format.html
|
||||
# format.api
|
||||
# end
|
||||
end
|
||||
|
||||
|
@ -301,7 +338,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 +354,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 +391,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 +401,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 +445,212 @@ 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)
|
||||
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")
|
||||
# or exists (select 1 from courses c2,members m2 where c2.id=m2.course_id and c2.id=#{Course.table_name}.id and m2.user_id= User.current.id)
|
||||
end
|
||||
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where("( (#{Course.table_name}.updated_at=? and #{Course.table_name}.id < ?) or #{Course.table_name}.updated_at<?)",params[:lasttime],params[:lastid],params[:lasttime])
|
||||
end
|
||||
@list = query.order("#{Course.table_name}.updated_at desc,#{Course.table_name}.id desc").limit(8).all
|
||||
|
||||
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
|
||||
# @list = []
|
||||
# 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_rec_count = 8
|
||||
# query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
||||
# query_i = 0;
|
||||
# while( true )
|
||||
# query_i = query_i+1
|
||||
# if(query_i>query_times)
|
||||
# break
|
||||
# end
|
||||
# query = Activity.where(user_id: user_ids)
|
||||
# if(lastid != nil)
|
||||
# query = query.where("id < ?",lastid)
|
||||
# end
|
||||
# lastid,item_list = query_activities(query,'course');
|
||||
# for item in item_list
|
||||
# @list << item
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# if lastid == nil
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# render :layout=>nil
|
||||
# end
|
||||
#
|
||||
# def user_project_activities
|
||||
# @list = []
|
||||
# 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_rec_count = 8
|
||||
# query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
||||
# query_i = 0;
|
||||
# while( true )
|
||||
# query_i = query_i+1
|
||||
# if(query_i>query_times)
|
||||
# break
|
||||
# end
|
||||
# query = Activity.where(user_id: user_ids)
|
||||
# if(lastid != nil)
|
||||
# query = query.where("id < ?",lastid)
|
||||
# end
|
||||
# lastid,item_list = query_activities(query,'project');
|
||||
# for item in item_list
|
||||
# @list << item
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# if lastid == nil
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# render :action=>'user_course_activities',: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 +666,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 +699,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 +718,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 +727,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 +744,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 +769,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 +817,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 +843,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
#### end
|
||||
|
||||
|
||||
|
||||
def new
|
||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||
|
@ -660,7 +901,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 +1071,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 +1176,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 +1204,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"
|
||||
|
|
|
@ -13,11 +13,12 @@ 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
|
||||
@jour = list.last
|
||||
# @user.count_new_jour
|
||||
# if a_message.size > 5
|
||||
# @message = a_message[-5, 5]
|
||||
# else
|
||||
|
@ -26,8 +27,8 @@ class WordsController < ApplicationController
|
|||
# @message_count = a_message.count
|
||||
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').reverse
|
||||
# @jour = paginateHelper @jours,10
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
||||
|
@ -88,6 +89,7 @@ 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
|
||||
|
|
|
@ -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,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
module ApiHelper
|
||||
#获取用户的工作单位
|
||||
def get_user_work_unit user
|
||||
|
@ -64,4 +65,103 @@ module ApiHelper
|
|||
def get_user_language user
|
||||
(user.language.nil? || user.language == "") ? 'zh':user.language
|
||||
end
|
||||
|
||||
# 学生获取课程作业的状态
|
||||
def get_homework_status homework
|
||||
homework_status = ""
|
||||
if !homework.nil?
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
homework_status = show_homework_deadline homework
|
||||
when 2
|
||||
homework_status = "正在匿评"
|
||||
when 3
|
||||
homework_status = "匿评结束"
|
||||
end
|
||||
elsif homework.homework_type == 0
|
||||
homework_status = "未启用匿评"
|
||||
elsif homework.homework_type == 2
|
||||
homework_status = "编程作业"
|
||||
else
|
||||
end
|
||||
end
|
||||
homework_status
|
||||
end
|
||||
|
||||
#获取作业的是否可以匿评的描述
|
||||
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 = show_homework_deadline homework
|
||||
elsif homework.student_works.count >= 2 #作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
link = '启动匿评'
|
||||
when 2
|
||||
link = '关闭匿评'
|
||||
when 3
|
||||
link = " 匿评结束"
|
||||
end
|
||||
else
|
||||
link = "提交作业数过少"
|
||||
end
|
||||
else
|
||||
link = "未开启匿评作业"
|
||||
end
|
||||
link
|
||||
end
|
||||
|
||||
#获取
|
||||
def get_submit_sutdent_list homework
|
||||
studentlist = []
|
||||
if homework.is_a?(Hash) && homework.key?(:studentlist)
|
||||
studentlist = homework[:studentlist]
|
||||
else
|
||||
homework.student_works.order("created_at desc").page(1).per(6).each do |work|
|
||||
studentlist << work.user
|
||||
end
|
||||
end
|
||||
studentlist
|
||||
end
|
||||
|
||||
#计算作业的截止日期,剩余日期
|
||||
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
|
||||
"距作业截止还有" << 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
|
||||
|
||||
|
||||
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)
|
||||
|
@ -2278,7 +2281,9 @@ module ApplicationHelper
|
|||
#获取匿评相关连接代码
|
||||
def homework_anonymous_comment homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业
|
||||
if homework.student_works.count >= 2 #作业份数大于2
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
link = "<span class='fr mr10 pr_join_span ' title='作业截止日期之前不可以启动匿评'>启动匿评</span>".html_safe
|
||||
elsif homework.student_works.count >= 2 #作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit'
|
||||
|
@ -2290,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
|
||||
|
@ -2303,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
|
||||
|
@ -2322,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
|
||||
|
||||
|
@ -2337,4 +2346,36 @@ 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
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module CoursesHelper
|
|||
|
||||
#生成课程老师成员链接
|
||||
def course_teacher_link teacher_num
|
||||
if User.current.member_of_course?(@course)
|
||||
if User.current.member_of_course?(@course) || User.current.admin?
|
||||
link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue'
|
||||
else
|
||||
content_tag 'span',teacher_num, :class => 'info_foot_num c_blue'
|
||||
|
@ -44,7 +44,7 @@ module CoursesHelper
|
|||
|
||||
#生成课程学生列表连接
|
||||
def course_student_link student_num
|
||||
if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course))
|
||||
if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) || User.current.admin?
|
||||
link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue'
|
||||
else
|
||||
content_tag 'span',student_num, :class => 'info_foot_num c_blue'
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -15,7 +16,7 @@ module HomeworkCommonHelper
|
|||
#教辅评分比例下拉框
|
||||
def ta_proportion_option
|
||||
type = []
|
||||
i = 10
|
||||
i = 0
|
||||
while i <= 100
|
||||
option = []
|
||||
option << i.to_s + "%"
|
||||
|
@ -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,5 @@ module HomeworkCommonHelper
|
|||
end
|
||||
link
|
||||
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])
|
||||
|
@ -361,16 +381,15 @@ module IssuesHelper
|
|||
end
|
||||
end
|
||||
|
||||
# 之所以注释是因为该功能冗余了
|
||||
if detail.property == 'attr' && detail.prop_key == 'description'
|
||||
s = l(:text_journal_changed_no_detail, :label => label)
|
||||
# unless no_html
|
||||
# diff_link = link_to l(:label_diff),
|
||||
# {:controller => 'journals', :action => 'diff', :id => detail.journal_id,
|
||||
# :detail_id => detail.id, :only_path => options[:only_path]},
|
||||
# :title => l(:label_view_diff)
|
||||
# s << " (#{ diff_link })"
|
||||
# end
|
||||
unless no_html
|
||||
diff_link = link_to l(:label_diff),
|
||||
{:controller => 'journals', :action => 'diff', :id => detail.journal_id,
|
||||
:detail_id => detail.id, :only_path => options[:only_path]},
|
||||
:title => l(:label_view_diff)
|
||||
s << " (#{ diff_link })"
|
||||
end
|
||||
s.html_safe
|
||||
elsif detail.value.present?
|
||||
case detail.property
|
||||
|
|
|
@ -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,243 @@ 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)
|
||||
return Course.where("tea_id = ?",user.id).count()
|
||||
end
|
||||
def get_join_course_count(user)
|
||||
return user.coursememberships.count() - get_create_course_count(user)
|
||||
end
|
||||
def get_homework_commons_count(user)
|
||||
return HomeworkCommon.where("user_id = ?",user.id).count()
|
||||
end
|
||||
def get_projectandcourse_attachment_count(user)
|
||||
return Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count()
|
||||
end
|
||||
def get_create_project_count(user)
|
||||
return Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count()
|
||||
end
|
||||
def get_join_project_count(user)
|
||||
return user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user)
|
||||
end
|
||||
def get_create_issue_count(user)
|
||||
return Issue.where("author_id = ?",user.id).count()
|
||||
end
|
||||
def get_resolve_issue_count(user)
|
||||
return Issue.where("assigned_to_id = ? and status_id=3",user.id).count()
|
||||
end
|
||||
def get_anonymous_evaluation_count(user)
|
||||
return StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count()
|
||||
end
|
||||
|
||||
|
||||
# def query_activities(query,type)
|
||||
# query_rec_count = 8
|
||||
# # query = query.where("act_type='JournalsForMessage'")
|
||||
# #query = query.where("act_type not in (?)", ['JournalsForMessage','Message','HomeworkCommon','News','Issue','Journal','Poll'])
|
||||
# list = query.order("id desc").limit(query_rec_count).all
|
||||
#
|
||||
# result = [];
|
||||
# for item in list
|
||||
# container = get_activity_container(item,type)
|
||||
# if( activity_is_show(item,container) )
|
||||
# result << { :item=>item,:e=>container }
|
||||
# end
|
||||
# end
|
||||
# return [lastid,result]
|
||||
# end
|
||||
# def get_activity_container activity,type
|
||||
# e = nil;
|
||||
# if type == 'Project'
|
||||
# if activity.act_type == 'Poll'
|
||||
# # 项目没有问卷
|
||||
# # e = Project.find_by_id(activity.act.polls_group_id)
|
||||
# else
|
||||
# e = activity.act.project if activity.act.respond_to?('project')
|
||||
# end
|
||||
# end
|
||||
# if type == 'Course'
|
||||
# if activity.act_type == 'Poll'
|
||||
# e = Course.find_by_id(activity.act.polls_group_id)
|
||||
# else
|
||||
# e = activity.act.course if activity.act.respond_to?('course')
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# return e;
|
||||
# end
|
||||
def query_activities(query)
|
||||
list = query.limit(8).all
|
||||
result = [];
|
||||
for item in list
|
||||
container = get_activity_container(item)
|
||||
result << { :item=>item,:e=>container }
|
||||
end
|
||||
return result
|
||||
end
|
||||
def get_activity_container activity
|
||||
return activity.activity_container
|
||||
# if type == 'Project'
|
||||
# return activity.act.project if activity.act.respond_to?('project')
|
||||
# end
|
||||
# if type == 'Course'
|
||||
# if activity.act_type == 'Poll'
|
||||
# return Course.find_by_id(activity.act.polls_group_id)
|
||||
# end
|
||||
# return activity.act.course if activity.act.respond_to?('course')
|
||||
# end
|
||||
# return nil;
|
||||
end
|
||||
|
||||
# def activity_is_show(activity,e)
|
||||
# if(!e)
|
||||
# return false
|
||||
# end
|
||||
#
|
||||
# if activity.user_id == User.current.id
|
||||
# return true
|
||||
# end
|
||||
# if( e.visible? )
|
||||
# return true
|
||||
# end
|
||||
# return false
|
||||
# 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
|
||||
|
|
|
@ -19,6 +19,14 @@ class Comment < ActiveRecord::Base
|
|||
include Redmine::SafeAttributes
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
acts_as_event :datetime => :updated_on,
|
||||
:description => :comments,
|
||||
:type => 'news',
|
||||
:title=>Proc.new {|o| "RE: #{o.commented.title}" },
|
||||
:url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.commented.id} }
|
||||
|
||||
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :comments
|
||||
|
@ -38,4 +46,17 @@ class Comment < ActiveRecord::Base
|
|||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::COMMENT
|
||||
end
|
||||
|
||||
def set_notify_id(notify_id)
|
||||
@notify_id= notify_id
|
||||
end
|
||||
def get_notify_id()
|
||||
return @notify_id
|
||||
end
|
||||
def set_notify_is_read(notify_is_read)
|
||||
@notify_is_read = notify_is_read
|
||||
end
|
||||
def get_notify_is_read()
|
||||
return @notify_is_read
|
||||
end
|
||||
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
|
|
@ -2,4 +2,5 @@ class HomeworkTest < ActiveRecord::Base
|
|||
attr_accessible :input, :output, :homework_common_id
|
||||
|
||||
belongs_to :homework_common
|
||||
has_one :student_work_test
|
||||
end
|
||||
|
|
|
@ -104,13 +104,13 @@ class Mailer < ActionMailer::Base
|
|||
|
||||
# 查询user的缺陷,项目中成员都能收到
|
||||
sql = "select DISTINCT * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}'
|
||||
and (i.updated_on between '#{date_from}' and '#{date_to}') order by i.updated_on desc"
|
||||
and (i.updated_on between '#{date_from}' and '#{date_to}') order by i.project_id, i.updated_on desc"
|
||||
@issues = Issue.find_by_sql(sql)
|
||||
|
||||
# issue回复
|
||||
@issues_journals = Journal.find_by_sql("select j.* from journals j, members m, projects p, issues i
|
||||
where m.user_id = '#{user.id}' and p.id = m.project_id and i.project_id = p.id and j.journalized_id = i.id
|
||||
and j.journalized_type='Issue' and (j.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and j.journalized_type='Issue' and (j.created_on between '#{date_from}' and '#{date_to}') order by i.project_id, created_on desc")
|
||||
|
||||
# @bids 查询课程作业,包括老师发布的作业,以及user提交作业
|
||||
# @attachments查询课程课件更新
|
||||
|
@ -121,16 +121,16 @@ class Mailer < ActionMailer::Base
|
|||
count = count - 1
|
||||
for i in 0..count do
|
||||
bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc")
|
||||
attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC')
|
||||
attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'")
|
||||
@bids += bids if bids.count > 0
|
||||
@attachments += attachments if attachments.count > 0
|
||||
|
||||
end
|
||||
# @bids = @bids.sort_by { |obj| obj.created_at }
|
||||
end
|
||||
|
||||
# 项目附件
|
||||
@project_attachments = Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a
|
||||
where a.container_id = m.project_id and m.user_id='#{user.id}' and container_type = 'Project' and (a.created_on between '#{date_from}' and '#{date_to}') order by a.created_on desc")
|
||||
where a.container_id = m.project_id and m.user_id='#{user.id}' and container_type = 'Project' and (a.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, a.created_on desc")
|
||||
|
||||
# user 提交的作业
|
||||
# @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
|
||||
|
@ -138,18 +138,18 @@ class Mailer < ActionMailer::Base
|
|||
# 查询user所在项目添加wiki
|
||||
@wiki_contents = WikiContent.find_by_sql("select DISTINCT wc.* from wikis w, members m, projects p, wiki_pages wp, wiki_contents wc where
|
||||
m.user_id = '#{user.id}' and m.project_id = p.id and w.project_id = p.id and w.id = wp.wiki_id and wc.page_id = wp.id and w.project_id>0
|
||||
and (wc.updated_on between '#{date_from}' and '#{date_to}') order by updated_on desc")
|
||||
and (wc.updated_on between '#{date_from}' and '#{date_to}') order by m.project_id, updated_on desc")
|
||||
|
||||
# 查询user在课程中发布的讨论帖子
|
||||
course_mesages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where
|
||||
b.id = me.board_id and b.course_id = m.course_id
|
||||
and b.course_id is not Null and m.user_id = '#{user.id}'
|
||||
and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and (me.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
|
||||
|
||||
# 查询user在项目中发布的讨论帖子
|
||||
project_messages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where
|
||||
b.id = me.board_id and b.project_id = m.project_id
|
||||
and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
|
||||
# messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
@course_messages ||= []
|
||||
@project_messages ||= []
|
||||
|
@ -168,31 +168,31 @@ class Mailer < ActionMailer::Base
|
|||
# 查询user在课程中发布的通知和回复通知
|
||||
@course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
|
||||
where n.course_id in (#{course_ids})
|
||||
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
|
||||
and (created_on between '#{date_from}' and '#{date_to}') order by n.course_id, created_on desc") : []
|
||||
|
||||
@course_news_comments = Comment.find_by_sql("select cm.* from comments cm, members m, courses c, news n
|
||||
where m.user_id = '#{user.id}' and c.id = m.course_id and n.course_id = c.id and cm.commented_id = n.id
|
||||
and cm.commented_type ='News' and (cm.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and cm.commented_type ='News' and (cm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
|
||||
|
||||
# 查询user在项目中添加新闻和回复新闻
|
||||
@project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
|
||||
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
|
||||
and (created_on between '#{date_from}' and '#{date_to}') order by n.project_id, created_on desc") : []
|
||||
|
||||
@project_news_comments = Comment.find_by_sql("select c.* from comments c, members m, projects p, news n
|
||||
where m.user_id = '#{user.id}' and p.id = m.project_id and n.project_id = p.id and c.commented_id = n.id
|
||||
and c.commented_type ='News' and (c.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and c.commented_type ='News' and (c.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
|
||||
|
||||
# 查询user在课程及个人中留言
|
||||
@course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, courses c
|
||||
where m.user_id = '#{user.id}' and c.id = m.course_id and jfm.jour_id = c.id
|
||||
and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc")
|
||||
|
||||
@user_journal_messages = user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
|
||||
|
||||
# 查询user在项目中留言(用户反馈)
|
||||
@project_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p
|
||||
where m.user_id = '#{user.id}' and p.id = m.project_id and jfm.jour_id = p.id
|
||||
and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
|
||||
and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc")
|
||||
|
||||
# 查询user新建贴吧或发布帖子
|
||||
@forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,7 +9,7 @@ class Memo < ActiveRecord::Base
|
|||
# 若是主题帖,则内容可以是空
|
||||
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
||||
validates_length_of :subject, maximum: 50
|
||||
#validates_length_of :content, maximum: 3072
|
||||
validates_length_of :content, maximum: 5000
|
||||
validate :cannot_reply_to_locked_topic, :on => :create
|
||||
|
||||
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC"
|
||||
|
|
|
@ -30,6 +30,8 @@ class News < ActiveRecord::Base
|
|||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
validates_presence_of :title, :description
|
||||
validates_length_of :title, :maximum => 60
|
||||
validates_length_of :summary, :maximum => 255
|
||||
|
@ -85,6 +87,19 @@ class News < ActiveRecord::Base
|
|||
#description
|
||||
end
|
||||
|
||||
def set_notify_id(notify_id)
|
||||
@notify_id= notify_id
|
||||
end
|
||||
def get_notify_id()
|
||||
return @notify_id
|
||||
end
|
||||
def set_notify_is_read(notify_is_read)
|
||||
@notify_is_read = notify_is_read
|
||||
end
|
||||
def get_notify_is_read()
|
||||
return @notify_is_read
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -842,7 +843,7 @@ class Project < ActiveRecord::Base
|
|||
# Yields the given block for each project with its level in the tree
|
||||
def self.project_tree(projects, &block)
|
||||
ancestors = []
|
||||
projects.sort_by(&:lft).each do |project|
|
||||
projects.sort_by(&:id).each do |project|
|
||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||
ancestors.pop
|
||||
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]
|
||||
]
|
||||
|
||||
|
|
|
@ -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分页功能,每页显示的课程数
|
||||
|
@ -120,10 +121,10 @@ class CoursesService
|
|||
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
|
||||
raise '403'
|
||||
end
|
||||
scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user)
|
||||
scope = @course ? @course.news.order("news.created_on desc").course_visible(current_user) : News.order("news.created_on desc").course_visible(current_user)
|
||||
news = []
|
||||
scope.each do |n|
|
||||
news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
|
||||
news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :author=>n.author, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
|
||||
end
|
||||
news
|
||||
end
|
||||
|
@ -201,12 +202,14 @@ class CoursesService
|
|||
@course.class_period = params[:class_period].to_i
|
||||
params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0
|
||||
params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
|
||||
if @course.save
|
||||
if @course && @course.save
|
||||
#unless User.current.admin?
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => current_user, :roles => [r])
|
||||
|
@ -330,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.order('end_time 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
|
||||
|
@ -432,24 +435,15 @@ class CoursesService
|
|||
# 课程课件
|
||||
def course_attachments params
|
||||
result = []
|
||||
@course = Course.find(params[:course_id])
|
||||
@attachments = @course.attachments.order("created_on desc")
|
||||
course = Course.find(params[:course_id])
|
||||
attachments = course.attachments.order("created_on ")
|
||||
if !params[:name].nil? && params[:name] != ""
|
||||
@attachments.each do |atta|
|
||||
result << {:filename => atta.filename,
|
||||
:description => atta.description,
|
||||
:downloads => atta.downloads,
|
||||
:quotes => atta.quotes.nil? ? 0 :atta.quotes } if atta.filename.include?(params[:name])
|
||||
attachments.each do |atta|
|
||||
result << atta if atta.filename.include?(params[:name])
|
||||
|
||||
end
|
||||
else
|
||||
@attachments.each do |atta|
|
||||
result << {:filename => atta.filename,
|
||||
:description => atta.description,
|
||||
:downloads => atta.downloads,
|
||||
:quotes => atta.quotes.nil? ? 0 :atta.quotes }
|
||||
|
||||
end
|
||||
result = attachments
|
||||
end
|
||||
result
|
||||
end
|
||||
|
@ -540,14 +534,46 @@ class CoursesService
|
|||
#student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
description = bid.description
|
||||
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
|
||||
state = bid.homework_detail_manual.comment_status
|
||||
unless is_course_teacher
|
||||
homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user
|
||||
#state = bid.homework_detail_manual.comment_status
|
||||
if !bid.nil?
|
||||
if bid.homework_type == 1 && bid.homework_detail_manual
|
||||
case bid.homework_detail_manual.comment_status
|
||||
when 1
|
||||
state = show_homework_deadline bid
|
||||
when 2
|
||||
state = "正在匿评中"
|
||||
when 3
|
||||
state = "匿评已结束"
|
||||
end
|
||||
elsif bid.homework_type == 0
|
||||
state = "未启用匿评"
|
||||
elsif bid.homework_type == 2
|
||||
state = "编程作业"
|
||||
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
|
||||
#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}
|
||||
{: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
|
||||
|
||||
|
@ -615,9 +641,226 @@ class CoursesService
|
|||
homework_scores
|
||||
end
|
||||
|
||||
#app新版api
|
||||
#
|
||||
#
|
||||
#课程动态
|
||||
public
|
||||
def all_course_dynamics params, current_user
|
||||
#获取当前用户的所有课程
|
||||
@user = User.find(params[:id])
|
||||
if current_user.nil? && !current_user.admin? && !@user.active?
|
||||
raise '404'
|
||||
return
|
||||
end
|
||||
if current_user == @user || current_user.admin?
|
||||
membership = @user.coursememberships.page(1).per(15)
|
||||
else
|
||||
membership = @user.coursememberships.page(1).per(15).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 }
|
||||
|
||||
#定义一个数组集合,存放hash数组,该hash数组包括课程的信息,并包含课程的最新发布的资源,最新的讨论区留言,最新的作业,最新的通知
|
||||
result = []
|
||||
#对用户所有的课程进行循环,找到每个课程最新发布的资源,最新的讨论区留言,最新的作业,最新的通知,并存进数组
|
||||
membership.each do |mp|
|
||||
course = mp.course
|
||||
latest_course_dynamics = []
|
||||
|
||||
# 课程通知
|
||||
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}
|
||||
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}
|
||||
end
|
||||
|
||||
# 课程资源
|
||||
# latest_attachment = course.attachments.order("created_on desc").page(1).per(2)
|
||||
# unless latest_attachment.first.nil?
|
||||
# latest_course_dynamics << {:type => 3, :time => latest_attachment.first.created_on,:count =>course.attachments.count , :documents=>latest_attachment}
|
||||
# dynamics_count += 1
|
||||
# end
|
||||
|
||||
#课程作业 已经交的学生列表(暂定显示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}
|
||||
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 <<{:type=> 6,:time=>"1970-01-01 0:0:0 +0800",:count=> 4,:better_students=> better_students}
|
||||
end
|
||||
unless active_students.empty?
|
||||
latest_course_dynamics <<{:type=> 7,:time=>"1970-01-01 0:0:0 +0800",:count=> 4,:active_students=>active_students}
|
||||
end
|
||||
latest_course_dynamic = latest_course_dynamics.first
|
||||
unless latest_course_dynamic.nil?
|
||||
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,:message => "", :dynamics => latest_course_dynamics,
|
||||
: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=>latest_course_dynamic[:time].to_time}
|
||||
end
|
||||
end
|
||||
#返回数组集合
|
||||
result.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
result
|
||||
end
|
||||
|
||||
# 获取课程历次作业的学生总成绩
|
||||
def students_score_list params,current_user
|
||||
page = (params[:page] || 1) - 1
|
||||
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 = current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
student_works = []
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
show_all = is_teacher || homework.homework_type != 1 || homework.homework_detail_manual.comment_status == 3
|
||||
if show_all
|
||||
if homework.homework_type == 1 || is_teacher || current_user.admin?
|
||||
student_works = homework.student_works.page(params[:page] || 1).per(10).order("final_score desc ")
|
||||
else
|
||||
my_work = homework.student_works.where(:user_id => current_user.id)
|
||||
if my_work.empty?
|
||||
student_works = []
|
||||
else
|
||||
student_works = homework.student_works.page(params[:page] || 1).per(10).order("final_score desc")
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
student_works = homework.student_works.where(:user_id => current_user.id).page(params[:page] || 1).per(10)
|
||||
elsif homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
|
||||
#is_evaluation = true
|
||||
my_work = homework.student_works.where(:user_id => current_user.id).page(params[:page] || 1).per(10)
|
||||
student_works = my_work + current_user.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == homework.id}
|
||||
end
|
||||
end
|
||||
student_works
|
||||
end
|
||||
|
||||
# 获取课程的讨论区信息
|
||||
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 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
|
||||
|
||||
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 该作品的所有附件
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<div class="contextual">
|
||||
<%= link_to l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<h3>
|
||||
<%=l(:label_course_all)%>
|
||||
</h3>
|
||||
|
||||
<%= form_tag({}, :method => :get) do %>
|
||||
<fieldset>
|
||||
<label for='name'>
|
||||
课程:
|
||||
</label>
|
||||
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
|
||||
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
|
||||
<a class="icon icon-reload" onclick="$('#name').val('')" style="cursor: pointer;text-decoration: none;">
|
||||
<%= l(:button_clear)%>
|
||||
</a>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<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: 50px;">
|
||||
主讲老师
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
学时
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<%=l(:field_is_public)%>
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
<%=l(:field_created_on)%>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @courses.each do |course| %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= course.id %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=course.name%>'>
|
||||
<span>
|
||||
<%= link_to(course.name, course_path(course.id)) %>
|
||||
</span>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= course.class_period %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= checked_image course.is_public? %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(course.created_at) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_course_all)) -%>
|
|
@ -1,5 +1,5 @@
|
|||
<div class="contextual">
|
||||
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
|
||||
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<h3>
|
||||
|
@ -7,62 +7,70 @@
|
|||
</h3>
|
||||
|
||||
<%= form_tag({}, :method => :get) do %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
</legend>
|
||||
<label for='status'>
|
||||
<%= l(:field_status) %> :
|
||||
</label>
|
||||
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
|
||||
<label for='name'>
|
||||
<%= l(:label_project) %>:
|
||||
</label>
|
||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
|
||||
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
|
||||
</fieldset>
|
||||
</legend>
|
||||
<label for='status'>
|
||||
<%= l(:field_status) %> :
|
||||
</label>
|
||||
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %>
|
||||
<label for='name'>
|
||||
<%= l(:label_project) %>:
|
||||
</label>
|
||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
|
||||
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead><tr>
|
||||
<th>
|
||||
<%=l(:label_project)%>
|
||||
</th>
|
||||
<th>
|
||||
<%=l(:field_is_public)%>
|
||||
</th>
|
||||
<th>
|
||||
<%=l(:field_created_on)%>
|
||||
</th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% project_tree(@projects) do |project, level| %>
|
||||
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=project.name%>'>
|
||||
<span>
|
||||
<%= link_to_project_settings(project, {}) %>
|
||||
</span>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= checked_image project.is_public? %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= format_date(project.created_on) %>
|
||||
</td>
|
||||
<td class="buttons">
|
||||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
||||
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
|
||||
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
|
||||
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
<%=l(:label_project)%>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<%=l(:field_is_public)%>
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
<%=l(:field_created_on)%>
|
||||
</th>
|
||||
<th style="width: 70px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% project_tree(@projects) do |project, level| %>
|
||||
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||||
<td style="text-align: center;">
|
||||
<%= project.id %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=project.name%>'>
|
||||
<span>
|
||||
<%= link_to_project_settings(project, {}) %>
|
||||
</span>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= checked_image project.is_public? %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= format_date(project.created_on) %>
|
||||
</td>
|
||||
<td class="buttons">
|
||||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
||||
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
|
||||
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
|
||||
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_project_plural)) -%>
|
||||
|
|
|
@ -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>
|
||||
|
@ -70,31 +68,41 @@
|
|||
//解决由于图片加载慢造成div高度不够 以至于展开按钮不显示的bug
|
||||
$(function(){
|
||||
function nh_show_btn(){
|
||||
if($("#contentmessage<%=topic.id %>").height()>182){
|
||||
$("#project_show_<%= topic.id%>").show();
|
||||
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(){
|
||||
lens--;
|
||||
if(lens <= 0){
|
||||
nh_show_btn();
|
||||
}
|
||||
}
|
||||
if(lens <= 0){
|
||||
nh_show_btn();
|
||||
}else{
|
||||
// lens--;
|
||||
// if(lens <= 0){
|
||||
// nh_show_btn();
|
||||
// }
|
||||
}
|
||||
if(lens > 0){
|
||||
$('img',div).load(function(){
|
||||
nh_load_img_end();
|
||||
});
|
||||
}
|
||||
nh_show_btn();
|
||||
// if(lens <= 0){
|
||||
// nh_show_btn();
|
||||
// }else{
|
||||
// $('img',div).load(function(){
|
||||
// nh_load_img_end();
|
||||
// });
|
||||
// }
|
||||
});
|
||||
</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 %>
|
||||
<!-- -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -112,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>
|
||||
|
||||
|
@ -153,14 +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"><%= textAreailizable message,:content,:attachments => message.attachments %></div>
|
||||
<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),
|
||||
|
@ -168,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') %>
|
||||
|
|
|
@ -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,157 +28,160 @@
|
|||
</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($("#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(){
|
||||
lens--;
|
||||
if(lens <= 0){
|
||||
nh_show_btn();
|
||||
}
|
||||
}
|
||||
if(lens <= 0){
|
||||
nh_show_btn();
|
||||
}else{
|
||||
$('img',div).load(function(){
|
||||
nh_load_img_end();
|
||||
<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){
|
||||
// nh_show_btn();
|
||||
// }else{
|
||||
// $('img',div).load(function(){
|
||||
// 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 %>
|
||||
|
@ -198,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>
|
|
@ -50,9 +50,6 @@
|
|||
}
|
||||
}
|
||||
</script>
|
||||
<div class="add_frame_header" >
|
||||
<%= l(:bale_news_notice) %>
|
||||
</div>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<%= f.text_field :title,
|
||||
|
|
|
@ -1,55 +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, 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>
|
||||
<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('');$('#edit_group_<%= group.id %>').slideToggle();$('#new_group_name').hide();">
|
||||
<img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" />
|
||||
</a>
|
||||
<% end %>
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
<% 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">
|
||||
|
|
|
@ -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 %>
|
|
@ -1,7 +1,8 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>');
|
||||
showModal('ajax-modal', '510px');
|
||||
showModal('ajax-modal', '540px');
|
||||
$('#ajax-modal').css('height','330px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
//$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').siblings().hide();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
|
||||
"<a href='javascript:' onclick='hidden_join_course_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().removeClass("alert_praise");
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
<div class="for_img_thumbnails">
|
||||
<% curse_attachments.each do |file| %>
|
||||
<% if file.is_public? || User.current.member_of_course?(course) %>
|
||||
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
|
||||
<div class="re_con_box" id="container_files_<%= file.id %>">
|
||||
<div class="">
|
||||
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||
download_named_attachment_path(file.id, file.filename),
|
||||
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
|
||||
<% if User.current.logged? %>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<div class="re_top">
|
||||
<%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search f_l",:remote=>true) do %>
|
||||
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
|
||||
<%= submit_tag "站内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %>
|
||||
<%= submit_tag "项目内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()", :style =>"width:72px;" %>
|
||||
<%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
|
||||
<% end %>
|
||||
<% manage_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||
|
|
|
@ -21,14 +21,26 @@
|
|||
$("#attachments_fields").children().remove();
|
||||
$("#upload_file_count").text("未上传文件");
|
||||
$('#upload_file_div').slideToggle('slow');
|
||||
<% if @project%>
|
||||
<% if @project %>
|
||||
closeModal();
|
||||
$("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>');
|
||||
// 添加文件上传成功提示
|
||||
<% unless params[:attachments].nil? %>
|
||||
var div = $('<div id="addBox" class="flash notice">文件上传成功!</div>');
|
||||
$("#course_list").prepend(div);
|
||||
setTimeout( function(){div.remove();},3000)
|
||||
<% end %>
|
||||
<%elsif @course%>
|
||||
closeModal();
|
||||
$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>');
|
||||
$("#courses_files_count_info").html("<%= @all_attachments.count%>");
|
||||
$("#courses_files_count_nav").html("(<%= @all_attachments.count%>)")
|
||||
// 添加文件上传成功提示,
|
||||
<% unless params[:attachments].nil? %>
|
||||
var div = $('<div id="addBox" class="flash notice">文件上传成功!</div>');
|
||||
$("#course_list").prepend(div);
|
||||
setTimeout( function(){div.remove();},3000)
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
$(document).ready(img_thumbnails);
|
||||
|
|
|
@ -2,26 +2,29 @@
|
|||
<% if file.is_public? || User.current.member_of_course?(course) %>
|
||||
<div class="re_con_box" id="container_files_<%= file.id %>">
|
||||
<div class="">
|
||||
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s,:class => "c_dblue f_14 f_b f_l hiddent" %>
|
||||
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||
download_named_attachment_path(file.id, file.filename),
|
||||
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
|
||||
<% if User.current.logged? %>
|
||||
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
|
||||
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
|
||||
|
||||
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
|
||||
<span id="is_public_<%= file.id %>">
|
||||
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
|
||||
</span>
|
||||
<span id="is_public_<%= file.id %>">
|
||||
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
|
||||
</span>
|
||||
<% else %>
|
||||
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
|
||||
<% end %>
|
||||
<%= file_preview_tag(file, class: 'f_l re_open') %>
|
||||
<% else %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="">
|
||||
<div class="mt5">
|
||||
<p class="f_l mb5 c_grey02">文件大小:<%= number_to_human_size(file.filesize) %></p>
|
||||
<%= link_to( l(:button_delete), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%>
|
||||
|
|
|
@ -1,44 +1,48 @@
|
|||
<script>$(function(){$("img").removeAttr("alt");});</script>
|
||||
<div class="borad-topic-count">共有 <%=link_to @forum.memos.count %> 个贴子</div>
|
||||
<div style="padding-top: 10px">
|
||||
<% if memos.any? %>
|
||||
<% memos.each do |topic| %>
|
||||
<table class="content-text-list">
|
||||
<tr><td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%></td>
|
||||
<td>
|
||||
<table width="630px" border="0">
|
||||
<tr>
|
||||
<td valign="top" width="500px" class="<%= topic.sticky ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), forum_memo_path(topic.forum, topic) %></td>
|
||||
<td align="right" rowspan="3">
|
||||
<table class="borad-count">
|
||||
<tr>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">回答</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" ><span class="font_description"> </span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_at, topic.author %>
|
||||
<span class="font_description2">
|
||||
<% author = topic.last_reply.try(:author)%>
|
||||
<% if author%>
|
||||
最后回复:<%=link_to_user author %>
|
||||
<% end%>
|
||||
</span>
|
||||
<br />
|
||||
</span></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<div class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></div>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
<% if memos.any? %>
|
||||
<% memos.each do |topic| %>
|
||||
<table class="content-text-list">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" style="width: 50px;">
|
||||
<%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%>
|
||||
</td>
|
||||
<td>
|
||||
<table width="630px" border="0">
|
||||
<tr>
|
||||
<td valign="top" width="500px" class="<%= topic.sticky ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), forum_memo_path(topic.forum, topic) %></td>
|
||||
<td align="right" rowspan="3">
|
||||
<table class="borad-count">
|
||||
<tr>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">回答</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" ><span class="font_description"> </span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_at, topic.author %>
|
||||
<span class="font_description2">
|
||||
<% author = topic.last_reply.try(:author)%>
|
||||
<% if author%>
|
||||
最后回复:<%=link_to_user author %>
|
||||
<% end%>
|
||||
</span>
|
||||
<br />
|
||||
</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<div class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></div>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,54 +1,42 @@
|
|||
<!-- added by fq -->
|
||||
<div id="add-memo" class='lz' style="<% unless @memo.errors.any?%>display: none;<% end %> padding: 20px;">
|
||||
<h3>
|
||||
<%=l(:label_memo_new)%>
|
||||
</h3>
|
||||
<% if User.current.logged? %>
|
||||
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
|
||||
<div class="actions" style="max-width:680px">
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<p>
|
||||
<%= f.text_field :subject, :required => true, :maxlength => 50%>
|
||||
</p>
|
||||
<p style="max-width:680px">
|
||||
<%= f.kindeditor :content, :required => true %>
|
||||
</p>
|
||||
<!--<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>-->
|
||||
<p style="color: #ff0000">
|
||||
(<%= l(:label_memos_max_length) %>)
|
||||
</p>
|
||||
<p class="fl" style="margin-top: 5px;">
|
||||
<%= l(:label_attachment_plural) %>
|
||||
<br />
|
||||
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<%= f.submit :value => l(:label_memo_create) %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<h3>
|
||||
<%=l(:label_memo_new)%>
|
||||
</h3>
|
||||
<% if User.current.logged? %>
|
||||
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
|
||||
<div class="actions" style="max-width:680px">
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<p>
|
||||
<%= f.text_field :subject, :required => true, :maxlength => 50%>
|
||||
</p>
|
||||
<p style="max-width:680px">
|
||||
<%= f.kindeditor :content, :required => true %>
|
||||
</p>
|
||||
<!--<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>-->
|
||||
<p style="color: #ff0000">
|
||||
(<%= l(:label_memos_max_length) %>)
|
||||
</p>
|
||||
<p class="fl" style="margin-top: 5px;">
|
||||
<%= l(:label_attachment_plural) %>
|
||||
<br />
|
||||
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<%= f.submit :value => l(:label_memo_create) %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<!--modified by huang-->
|
||||
<% #= link_to '发布帖子', new_forum_memo_path(@forum), :class => 'icon icon-add' %>
|
||||
<span class="contextual-borad">
|
||||
<%= link_to(
|
||||
image_tag('edit.png')+l(:label_forum_edit),
|
||||
{:action => 'edit', :id => @forum},
|
||||
:method => 'get',
|
||||
:title => l(:button_edit)
|
||||
) if @forum.editable_by?(User.current) %>
|
||||
<%= link_to(
|
||||
image_tag('delete.png')+'删除讨论区',
|
||||
{:action => 'destroy', :id => @forum},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
<%= link_to(image_tag('edit.png')+l(:label_forum_edit),{:action => 'edit', :id => @forum}, :method => 'get', :title => l(:button_edit)) if @forum.editable_by?(User.current) %>
|
||||
<%= link_to(image_tag('delete.png')+'删除讨论区', {:action => 'destroy', :id => @forum}, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete)
|
||||
) if @forum.destroyable_by?(User.current) %>
|
||||
</span>
|
||||
<span>
|
||||
<%= link_to l(:label_memo_new_from_forum), new_forum_memo_path(@forum), :class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %>
|
||||
:onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %>
|
||||
</span>
|
||||
|
||||
<%= render :partial => 'forums/show_topics', :locals => {:memos => @memos} %>
|
||||
|
|
|
@ -1,42 +1,4 @@
|
|||
<%= stylesheet_link_tag 'css', :media => 'all' %>
|
||||
<script type="text/javascript" language="javascript" xmlns="http://www.w3.org/1999/html">
|
||||
function regexName()
|
||||
{
|
||||
var name = $.trim($("#homework_attach_name").val());
|
||||
|
||||
if(name=="")
|
||||
{
|
||||
$("#homework_attach_name_span").text("作品名称不能为空");
|
||||
$("#homework_attach_name_span").css('color','#ff0000');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_attach_name_span").text("填写正确");
|
||||
$("#homework_attach_name_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function regexDescription()
|
||||
{
|
||||
var name = $.trim($("#homework_attach_description").val());
|
||||
|
||||
if(name=="")
|
||||
{
|
||||
$("#homework_attach_description_span").text("作品描述不能为空");
|
||||
$("#homework_attach_description_span").css('color','#ff0000');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_attach_description_span").text("填写正确");
|
||||
$("#homework_attach_description_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function submit_homework_form(){if(regexName()&®exDescription()){$('#new_homework_attach').submit();}}
|
||||
</script>
|
||||
<div class="container" id="content">
|
||||
<div class="Newwork">
|
||||
<div id="tb_" class="tb_">
|
||||
|
@ -69,7 +31,7 @@
|
|||
</span>
|
||||
作品名称 :
|
||||
</label>
|
||||
<%= f.text_field "name", :required => true, :size => 60, :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onkeyup => "regexName();" %>
|
||||
<%= f.text_field "name", :required => true, :size => 60, :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onkeyup => "regexHomeworkCommonName();" %>
|
||||
<span id="homework_attach_name_span"></span>
|
||||
</p>
|
||||
<p style="float:left;">
|
||||
|
@ -79,7 +41,7 @@
|
|||
</span>
|
||||
作品描述 :
|
||||
</label>
|
||||
<%= f.text_area "description", :class => "w620", :maxlength => 3000, :style => "width:430px", :placeholder => "最多3000个汉字", :onkeyup => "regexDescription();"%>
|
||||
<%= f.text_area "description", :class => "w620", :maxlength => 3000, :style => "width:430px", :placeholder => "最多3000个汉字", :onkeyup => "regexHomeworkCommonDescription();"%>
|
||||
<p id="homework_attach_description_span" style="padding-left: 100px;"></p>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
<p>
|
||||
开启匿评后学生将不能对作品进行
|
||||
<span class="c_blue">修改、删除</span>
|
||||
等操作,目前有
|
||||
等操作,开启匿评后的提交作品,将
|
||||
<span class="c_blue">不能参与匿评</span>,
|
||||
匿评评分将被记为
|
||||
<span class="c_pink">0分</span>
|
||||
。目前有
|
||||
<span class="c_pink"><%= @totle_size%>个</span>
|
||||
学生,共提交了
|
||||
<span class="c_pink"><%= @cur_size %></span>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<div class="cl"></div>
|
||||
<li >
|
||||
<label class="label02 "> <%= l(:field_quote)%>: </label>
|
||||
<!--<textarea name="" placeholder="请在此填入作业的要求及评分依据" class=" w548 h150 mb10 fl" ></textarea>-->
|
||||
<div style="width: 83%;float: left;">
|
||||
<% if edit_mode %>
|
||||
<%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %>
|
||||
|
@ -47,7 +46,7 @@
|
|||
<p class="fl ml20 f14 mb10 c_orange">基本规则设置(总分为100分)</p>
|
||||
<div class="cl"></div>
|
||||
<ul class="ml10">
|
||||
<li style="display: none;">
|
||||
<li>
|
||||
<label class="label02">迟交扣分: </label>
|
||||
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<span class="fl mt5"> 分</span>
|
||||
|
@ -99,11 +98,11 @@
|
|||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
<li style="display: none;">
|
||||
<li>
|
||||
<label class="label02">缺评扣分: </label>
|
||||
<%= select_tag :absence_penalty,options_for_select(absence_penalty_option,homework.homework_detail_manual.absence_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<span class="fl mt5"> 分</span>
|
||||
<p class="ml5 fl mt5">学生漏评1个作品将扣<span class="c_red" id="absence_penalty_notice"> 2 </span>分</p>
|
||||
<p class="ml5 fl mt5">学生漏评1个作品将扣<span class="c_red" id="absence_penalty_notice"> <%= homework.homework_detail_manual.absence_penalty%> </span>分</p>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
</ul> <!-- h1 end--->
|
|
@ -0,0 +1,123 @@
|
|||
<ul class="hwork_new_basic">
|
||||
<li >
|
||||
<label class="label02 mb20">
|
||||
<span class="c_red">*</span>
|
||||
<%= l(:field_name)%>:
|
||||
</label>
|
||||
<input type="text" name="homework_common[name]" id="homework_name" class="w548 h26 fl" maxlength="255" onkeyup="regex_homework_name();" value="<%= homework.name%>" >
|
||||
<p id="homework_name_span" class="c_red ml110"></p>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li >
|
||||
<label class="label02 "> <%= l(:field_quote)%>: </label>
|
||||
<div style="width: 83%;float: left;">
|
||||
<% if edit_mode %>
|
||||
<%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %>
|
||||
<% else %>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<%= f.kindeditor :description,:editor_id => 'homework_description_editor' %>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="mt10">
|
||||
<label class="label02"> 附件: </label>
|
||||
<%= render :partial => 'attachments/new_form', :locals => {:container => homework} %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="fl">
|
||||
<label class="label02">
|
||||
<span class="c_red">*</span>
|
||||
<%= l(:label_limit_time)%>:
|
||||
</label>
|
||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="hwork_input02 fl" readonly="readonly" value="<%= homework.end_time%>" >
|
||||
<%= calendar_for('homework_end_time')%>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li class="fl ml100" style="display: none;">
|
||||
<label class="label02"> 发布日期: </label>
|
||||
<input type="text" name="homework_common[publish_time]" id="homework_publish_time" class="hwork_input02 fl" readonly="readonly" value="<%= homework.publish_time%>" >
|
||||
<%= calendar_for('homework_publish_time')%>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="label02">迟交扣分: </label>
|
||||
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<span class="fl mt5"> 分</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
</ul><!--hwork_new_basic end--->
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="hwork_new_set">
|
||||
<p class="fl ml20 f14 mb10 c_orange">编程评测设置</p>
|
||||
<div class="cl"></div>
|
||||
<ul>
|
||||
<li >
|
||||
<label class="label02"> 开发语言: </label>
|
||||
<%= select_tag :language,options_for_select(programing_languages_options,homework.homework_detail_programing.language), {:class => "fl mb10 h26 w70"} %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<label class="label02">评分比例: </label>
|
||||
<%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "fl mb10 h26 w70"} %>
|
||||
<span class="ml5 fl mt5">× 教辅评分</span>
|
||||
<span class="ml5 fl mt5"> + </span>
|
||||
<input type="text" id="student_proportion" value="<%= (100 - homework.homework_detail_programing.ta_proportion* 100).to_i%>%" class="fl mb10 h26 w70" readonly>
|
||||
<span class="ml5 fl mt5">× 系统评分</span>
|
||||
<span class="ml5 fl mt5">= 学生得分</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<label class="label02" > </label>
|
||||
<span class=" fl c_red">如果教师对学生作品进行了评分,则教师评分为学生最终得分。</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<label class="label02"> 标准代码: </label>
|
||||
<textarea name="standard_code" class=" w547 h150 mb10 fl"><%= homework.homework_detail_programing.standard_code%></textarea>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
<% if edit_mode %>
|
||||
<% homework.homework_tests.each do |homework_test|%>
|
||||
<div>
|
||||
<li>
|
||||
<label class="label02"> 测试输入: </label>
|
||||
<input type="text" class="fl h26 w200 mb10" name="input[<%= homework_test.id%>]" value="<%= homework_test.input%>"/>
|
||||
</li>
|
||||
<li >
|
||||
<label class=" fl f14 ml10"> 输出: </label>
|
||||
<input type="text" class="fl h26 w200 mb10" name="output[<%= homework_test.id%>]" value="<%= homework_test.output%>"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<!--span class="green_btn fl ml5 mt1">测试</span-->
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end%>
|
||||
<% else %>
|
||||
<div>
|
||||
<li>
|
||||
<label class="label02"> 测试输入: </label>
|
||||
<input type="text" class="fl h26 w200 mb10" name="input[0]" />
|
||||
</li>
|
||||
<li >
|
||||
<label class=" fl f14 ml10"> 输出: </label>
|
||||
<input type="text" class="fl h26 w200 mb10" name="output[0]" />
|
||||
</li>
|
||||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<!--span class="green_btn fl ml5 mt1">测试</span-->
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
|
@ -7,10 +7,18 @@
|
|||
</h2>
|
||||
</div>
|
||||
<div class="hwork_new">
|
||||
<%= form_for @homework do |f| %>
|
||||
<%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('edit_homework_common_<%= @homework.id%>');" >提交</a>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<%if @homework.homework_type == 2%>
|
||||
<%= form_for @homework do |f| %>
|
||||
<%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('edit_homework_common_<%= @homework.id%>');" >提交</a>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<% end%>
|
||||
<% else %>
|
||||
<%= form_for @homework do |f| %>
|
||||
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('edit_homework_common_<%= @homework.id%>');" >提交</a>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<% end%>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -41,12 +41,39 @@
|
|||
<%= homework.description.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="news_foot currentDd" id="bid_show_more_des_button<%= homework.id%>" onclick="bid_show_more_des(<%= homework.id%>);" style="cursor:pointer;display: none;">
|
||||
<div class="news_foot currentDd fr" id="bid_show_more_des_button<%= homework.id%>" onclick="bid_show_more_des(<%= homework.id%>);" style="cursor:pointer;display: none;">
|
||||
[展开]
|
||||
</div>
|
||||
|
||||
<div class="cl"></div>
|
||||
|
||||
<% if homework.homework_type == 2 && homework.homework_detail_programing%>
|
||||
<table class="border_ce" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr class="<%= cycle("", "b_grey") %>">
|
||||
<td class="td_tit">
|
||||
输入
|
||||
</td>
|
||||
<td class="td_tit">
|
||||
输出
|
||||
</td>
|
||||
</tr>
|
||||
<% homework.homework_tests.each do |test|%>
|
||||
<tr class="<%= cycle("", "b_grey") %>">
|
||||
<td class="td_tit">
|
||||
<%=test.input%>
|
||||
</td>
|
||||
<td class="td_tit">
|
||||
<%= test.output%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end%>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt5">
|
||||
<% unless homework.attachments.empty?%>
|
||||
<span class="tit_fb" style="width: auto;"> 附件:</span>
|
||||
|
@ -55,7 +82,18 @@
|
|||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt5">
|
||||
<span class="tit_fb" style="width: auto;"> 扣分标准:</span>
|
||||
<div class="fl mb5 c_red">
|
||||
<% if homework.homework_type == 1%>
|
||||
<%= scoring_rules homework.late_penalty,homework.id,@is_teacher,homework.homework_detail_manual.absence_penalty%>
|
||||
<% else%>
|
||||
<%= scoring_rules homework.late_penalty,homework.id,@is_teacher%>
|
||||
<% end%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<span class="fl"><%= l(:label_end_time)%>:<%= homework.end_time%></span>
|
||||
|
|
|
@ -1,17 +1,27 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
<%= error_messages_for 'homework_common' %>
|
||||
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">
|
||||
<%= l(:label_course_homework_new)%>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="hwork_new">
|
||||
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
|
||||
<%= hidden_field_tag "course",@course.id%>
|
||||
<%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<div class="hwork_new" id="hwork_new">
|
||||
<%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%>
|
||||
<input type="hidden" name="course" value="<%= @course.id%>">
|
||||
<h3 class="c_blue f16 mb10">
|
||||
请选择将要发布的作业类型
|
||||
</h3>
|
||||
<input type="radio" class="mb10 fl" name="homework_common_type" value="1" id="homework_detail_manual_radio" checked/>
|
||||
<span class="ml5 fl">
|
||||
人工评分的作业(支持匿名互评、灵活设置评分比例)
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<input type="radio" class="mb20 fl" name="homework_common_type" value="2" id="homework_detail_programing_radio"/>
|
||||
<span class="ml5 fl">
|
||||
自动评测的编程作业(支持C/C++程序的自动评分)
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class=" orange_btn" onclick="$(this).parent().submit();">
|
||||
下一步
|
||||
</a>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= error_messages_for 'homework_common' %>
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">
|
||||
<%= l(:label_course_homework_new)%>
|
||||
</h2>
|
||||
</div>
|
||||
<% if @homework_type == "1"%>
|
||||
<div class="hwork_new">
|
||||
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
|
||||
<%= hidden_field_tag "course",@course.id%>
|
||||
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
|
||||
<%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
<% elsif @homework_type == "2"%>
|
||||
<div class="hwork_new">
|
||||
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
|
||||
<%= hidden_field_tag "course",@course.id%>
|
||||
<%= hidden_field_tag "homework_common[homework_type]","2"%>
|
||||
<%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
|
||||
<%= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
|
@ -5,6 +5,8 @@ $("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javasc
|
|||
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
|
||||
<% elsif @statue == 3%>
|
||||
alert("已开启匿评,请务重复开启");
|
||||
<% elsif @statue == 3%>
|
||||
<% elsif @statue == 4%>
|
||||
alert("您没有权限开启匿评");
|
||||
<% elsif @statue == 5%>
|
||||
alert("作业提交截止之后才能启动匿评");
|
||||
<% end %>
|
|
@ -5,7 +5,7 @@
|
|||
<% if @edit_allowed || !@allowed_statuses.empty? %>
|
||||
<div id="all_attributes" style="display:none;">
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<div class="ping_C mb10"></div>
|
||||
<div class="ping_C mb10 ml10"></div>
|
||||
<!--<a remote="true" href="javascript:void(0)" class="blue_btn fl" style="margin-left: 80px;margin-bottom: 10px;margin-top: -10px;" onclick="$('#issue-form').submit();">-->
|
||||
<!--<%#= l(:button_submit) %>-->
|
||||
<!--</a>-->
|
||||
|
@ -20,6 +20,8 @@
|
|||
<%= render :partial => 'history', :locals => {:issue => @issue, :journals => @journals} %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="journal_issue_note" class="wiki"></div>
|
||||
<input name="issue_quote_new" type="hidden" value="<%= %>" />
|
||||
<fieldset><legend>回复</legend>
|
||||
<%= f.text_area :notes, :style => "width:99%;", :rows => "5", :no_label => true %>
|
||||
</fieldset>
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
<% reply_links = authorize_for('issues', 'edit') -%>
|
||||
<% journals.reverse.each do |journal| %>
|
||||
<!-- modified by bai -->
|
||||
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>" style=" word-wrap: break-word; word-break: break-all">
|
||||
<!-- end -->
|
||||
<div class="ping_C mb10">
|
||||
<div class="ping_dispic"><a href="#" target="_blank"><%= image_tag(url_to_avatar(journal.user), :class => "ping_dispic",:width => 46,:height => 46) %></a></div>
|
||||
<div class="ping_discon">
|
||||
<div class="ping_distop">
|
||||
<a href="#" target="_blank" class="c_blue fb fl mb10 "><%= journal.user %></a><span class="c_grey fr"><%= format_time journal.created_on %></span>
|
||||
<!-- modified by bai -->
|
||||
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>" style=" word-wrap: break-word; word-break: break-all">
|
||||
<!-- end -->
|
||||
<div class="ping_C mb10 ml10">
|
||||
<div class="ping_dispic"><a href="#" target="_blank"><%= image_tag(url_to_avatar(journal.user), :class => "ping_dispic",:width => 46,:height => 46) %></a></div>
|
||||
<div class="ping_discon" style="width: 600px;">
|
||||
<div class="ping_distop">
|
||||
<a href="#" target="_blank" class="c_blue fb fl mb10 "><%= journal.user %></a><span class="c_grey fr"><%= format_time journal.created_on %></span>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
<% if journal.details.any? %>
|
||||
<% details_to_strings(journal.details).each do |string| %>
|
||||
<p><%= string %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<!--编辑、引用、回复按钮-->
|
||||
<div class="ping_disfoot"><%= render_links_easy(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %></div>
|
||||
<!--回复内容、引用内容-->
|
||||
<p><%= render_notes_issue(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %></p>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
<% if journal.details.any? %>
|
||||
<% details_to_strings(journal.details).each do |string| %>
|
||||
<p><%= string %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<!--编辑、引用、回复按钮-->
|
||||
<div class="ping_disfoot"><%= render_links_easy(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %></div>
|
||||
<!--回复内容、引用内容-->
|
||||
<p><%= render_notes_issue(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %></p>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
|
||||
<% end %>
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
<div class="problem_main">
|
||||
<% column_content = ( query.inline_columns.map {|column| "#{column_content_new(column, issue)}"}) %>
|
||||
<% unless issue.author.nil? || issue.author.name == "Anonymous" %>
|
||||
<span class="issues_icon fl"></span>
|
||||
<span class ="<%= get_issue_type(column_content[1])[0] %>" title="<%= get_issue_type(column_content[1])[1] %>"></span>
|
||||
<div class="problem_txt fl">
|
||||
<%= link_to issue.author.name, user_path(issue.author), :class => "problem_name c_orange fl" %>
|
||||
<span class="fl"><%= l(:label_post_on_issue) %>(<%= "#{raw column_content[2]}" %>):</span>
|
||||
<div class="problem_tit_div fl">
|
||||
<%=link_to "#{column_content[4]}<span class = '#{get_issue_type(column_content[1])[0]}'>#{get_issue_type(column_content[1])[1]}</span>".html_safe, issue_path(issue.id), :class => "problem_tit_a break_word",:target => "_blank" %>
|
||||
<div class="problem_tit_div fl break_word">
|
||||
<%=link_to "#{column_content[4]}<span class = '#{get_issue_priority(column_content[3])[0]}'>#{get_issue_priority(column_content[3])[1]}</span>".html_safe, issue_path(issue.id), :class => "problem_tit_a break_word",:target => "_blank" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
</div>
|
||||
<div class="talk_txt fl">
|
||||
<p class="pro_page_tit" style="word-break:break-all;">
|
||||
<%= @issue.subject %>
|
||||
<span class='<%= "#{get_issue_type(@issue.tracker_id)[0]}" %>'><%= get_issue_type(@issue.tracker_id)[1] %></span>
|
||||
<span class='<%= "#{get_issue_type(@issue.tracker_id)[0]} fl" %>' title="<%= get_issue_type(@issue.tracker_id)[1] %>"></span>
|
||||
<span style="padding-left: 5px;"><%= @issue.subject %></span>
|
||||
<span class='<%= "#{get_issue_priority(@issue.priority_id)[0]} " %>'><%= get_issue_priority(@issue.priority_id)[1] %></span>
|
||||
</p><br/>
|
||||
|
||||
<div class="cl"></div>
|
||||
|
@ -109,6 +110,9 @@
|
|||
<%= render :partial => 'edit' %>
|
||||
</div>
|
||||
<p style="padding-top: 5px"></p>
|
||||
|
||||
<!--引用时不能修改,剥离出引用内容-->
|
||||
|
||||
<a remote="true" href="javascript:void(0)" class="blue_btn fr mr80" onclick="issue_desc_editor.sync();$('#issue-form').submit();">
|
||||
<%= l(:button_submit) %>
|
||||
</a>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<h3><%=h @issue.tracker %> #<%= @issue.id %></h3>
|
||||
<p><%= authoring @journal.created_on, @journal.user, :label => :label_updated_time_by %></p>
|
||||
<p>由<%= @journal.user %> 更新于 <%= format_time @journal.created_on %></p>
|
||||
|
||||
<div class="text-diff">
|
||||
<%= simple_format_without_paragraph @diff.to_html %>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<div id="Footer">
|
||||
<ul class="copyright" style="text-align:center;">
|
||||
<li><%= @organizer.description.html_safe %></li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul class="footlogo">
|
||||
<% @companies && @companies.each do |company| %>
|
||||
<li class="fl" style="margin:0 8px;">
|
||||
<a href="<%= company.url %>" target="_blank" title="<%=company.name%>"><img src="<%= url_to_avatar(company) %>" width="100" height="30" alt="<%=company.name%>" /></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
|
@ -17,15 +17,14 @@
|
|||
visiable = hidden_non_project && hidden_non_project.value == "0"%>
|
||||
<ul class="sub_menu">
|
||||
<% if @show_course == 1 && !visiable %>
|
||||
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
|
||||
<% hasCourse=false %>
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<% hasCourse=true %>
|
||||
<% end %>
|
||||
<% hasCourse=false %>
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<% hasCourse=true %>
|
||||
<% break %>
|
||||
<% end %>
|
||||
<%= render :partial => 'layouts/user_courses_list', :locals => {:hasCourse => hasCourse} %>
|
||||
<% end -%>
|
||||
<% end %>
|
||||
<%= render :partial => 'layouts/user_courses_list', :locals => {:hasCourse => hasCourse} %>
|
||||
<% end %>
|
||||
<%= render :partial => 'layouts/user_project_list', :locals => {:hasCourse => hasCourse} %>
|
||||
<li style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
|
@ -102,10 +101,7 @@
|
|||
addSlipMenu();
|
||||
addProjectSlipMenu ();
|
||||
addCourseSlipMenu();
|
||||
});
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
$('.sub_menu').find("a").attr('target', '_blank');
|
||||
$('.sub_menu').find("a").attr('target', '_blank');
|
||||
$('.project_sub_menu').find("a").attr('target', '_blank');
|
||||
$('.course_sub_menu').find("a").attr('target', '_blank');
|
||||
});
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<div id="Header" >
|
||||
<div class="logo fl" >
|
||||
<%=link_to image_tag("/images/logo.png",weight:"35px", height: "30px")%>
|
||||
</div>
|
||||
<div id="TopNav" class="fl">
|
||||
<%= render_dynamic_nav if User.current.logged? || !Setting.login_required? -%>
|
||||
</div>
|
||||
<div id="TopUser" class="fr">
|
||||
<div id="menu">
|
||||
<ul class="menu">
|
||||
<% if User.current.logged? %>
|
||||
<li>
|
||||
<%=link_to_user(User.current)%><!--<a href="javascript:void(0);" class="parent">用户名称</a>-->
|
||||
<ul>
|
||||
<% hidden_non_project = Setting.find_by_name("hidden_non_project")
|
||||
visiable = hidden_non_project && hidden_non_project.value == "0"%>
|
||||
<% if @show_course == 1 && !visiable %>
|
||||
<%# if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
|
||||
<% hasCourse=false %>
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<% hasCourse=true %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if hasCourse %>
|
||||
<li>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的课程</a>
|
||||
<ul>
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<li title="<%=course.name%>"><a href="<%= url_for(:controller => 'courses', :action=>"show", :id=>course.id, :host=>Setting.host_course) %>"><%= course.name %></a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
<%# end -%>
|
||||
<% end %>
|
||||
|
||||
<% if User.current.projects.count>0 %>
|
||||
<li>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的项目</a>
|
||||
<ul>
|
||||
<% User.current.projects.each do |project| %>
|
||||
<li title="<%=project.name%>"><a href="<%= url_for(:controller => 'projects', :action=>"show", :id=>project.id, :host=>Setting.host_name) %>"><%=project.name%></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
<li><a href="<%= url_for(:controller => 'my', :action => 'account') %>">编辑资料</a></li>
|
||||
<!--<li><a href="javascript:void(0);" class="parent">我的课程</a>-->
|
||||
<!--<ul>-->
|
||||
<!--<li><a href="javascript:void(0);">新建课程</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);">我的课程0我的课程我的课程01我的课程011</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);">我的课程02</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);">我的课程02</a></li>-->
|
||||
<!--</ul><!–-level3 end-–>-->
|
||||
<!--</li><!–-level2 end-–>-->
|
||||
<!--<li><a href="javascript:void(0);" class="parent">我的项目</a>-->
|
||||
<!--<ul>-->
|
||||
<!--<li><a href="javascript:void(0);">新建项目</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);">我的项目01</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);">我的项目0</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);">我的项目02</a></li>-->
|
||||
<!--</ul><!–-level3 end-–>-->
|
||||
<!--</li><!–-level2 end-–>-->
|
||||
<!--<li><a href="javascript:void(0);">我的主页</a></li>-->
|
||||
</ul>
|
||||
</li><!---level1 end--->
|
||||
<!--<li ><a href="javascript:void(0);">退出</a></li>-->
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= render_menu :account_menu -%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -20,13 +20,13 @@
|
|||
<li id="current_user_li">
|
||||
<%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, target:"_blank", :class => "uses_name"%>
|
||||
<ul id="user_sub_menu" style="right: 0px;display: none;">
|
||||
<% if @show_course == 1 && User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) %>
|
||||
<% if @show_course == 1 %>
|
||||
<% user_course = get_user_course User.current%>
|
||||
<% unless user_course.empty? %>
|
||||
<li id="my_courses_li">
|
||||
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id},target:"_blank", :class => "parent" %>
|
||||
<ul id="my_courses_ul">
|
||||
<% user_course.each do |course| %>
|
||||
<% user_course.reverse.each do |course| %>
|
||||
<li title="<%=course.name%>">
|
||||
<%= link_to course.name, {:controller => 'courses',:action => 'show',:id => course.id},target:"_blank" %>
|
||||
</li>
|
||||
|
@ -40,7 +40,7 @@
|
|||
<li id="my_projects_li">
|
||||
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name},target:"_blank", :class => "parent" %>
|
||||
<ul id="my_projects_ul" >
|
||||
<% User.current.projects.each do |project| %>
|
||||
<% User.current.projects.reverse.each do |project| %>
|
||||
<li title="<%=project.name%>">
|
||||
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name }, target:"_blank" %>
|
||||
</li>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ul class="course_sub_menu">
|
||||
<% course_index = 0 %>
|
||||
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% User.current.courses.reverse.each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<%= render :partial => 'layouts/user_homework_list', :locals => {:course => course,:course_index => course_index} %>
|
||||
<% course_index += 1 %>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue