Merge branch 'develop' into ouyangxuhua

ouyangxuhua
ouyangxuhua 10 years ago
commit b581a13736

@ -17,7 +17,7 @@ gem 'daemons'
gem 'grape', '~> 0.9.0' gem 'grape', '~> 0.9.0'
gem 'grape-entity' gem 'grape-entity'
gem 'seems_rateable', '~> 1.0.13' gem 'seems_rateable', '~> 1.0.13'
gem "rails", "3.2.13" gem "rails", "~> 3.2.13"
gem "jquery-rails", "~> 2.0.2" gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0" gem "i18n", "~> 0.6.0"
gem 'coderay', '~> 1.1.0' gem 'coderay', '~> 1.1.0'

@ -24,7 +24,7 @@ class AdminController < ApplicationController
before_filter :require_admin before_filter :require_admin
helper :sort helper :sort
helper :Users helper :Users
helper :Settings helper :Settings,SchoolHelper
include SortHelper include SortHelper
def index def index
@ -40,12 +40,16 @@ class AdminController < ApplicationController
@projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all
=end =end
@projects = Project.like(@name).order('created_on desc') @projects = Project.like(@name).order('created_on desc')
@projects = paginateHelper @projects,30
@page = (params['page'] || 1).to_i - 1
render :action => "projects", :layout => false if request.xhr? render :action => "projects", :layout => false if request.xhr?
end end
def courses def courses
@name = params[:name] @name = params[:name]
@courses = Course.like(@name).order('created_at desc') @courses = Course.like(@name).order('created_at desc')
@courses = paginateHelper @courses,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format| respond_to do |format|
format.html format.html
end end
@ -61,7 +65,17 @@ class AdminController < ApplicationController
#管理员界面课程资源列表 #管理员界面课程资源列表
def course_resource_list def course_resource_list
@resource = Attachment.where(:container_type => 'Course')
if params[:sort] == 'file_size'
@resource = Attachment.where(:container_type => 'Course').order("filesize desc")
elsif params[:sort] == 'file_upload'
@resource = Attachment.where(:container_type => 'Course').order("created_on desc")
elsif params[:sort] == 'file_download_times'
@resource = Attachment.where(:container_type => 'Course').order("downloads desc")
else
@resource = Attachment.where(:container_type => 'Course').order("created_on desc")
end
@resource = paginateHelper @resource,30 @resource = paginateHelper @resource,30
@page = (params['page'] || 1).to_i - 1 @page = (params['page'] || 1).to_i - 1
@ -72,7 +86,17 @@ class AdminController < ApplicationController
#管理员界面項目资源列表 #管理员界面項目资源列表
def project_resource_list def project_resource_list
@pro_resource = Attachment.where(:container_type => 'Project')
if params[:sort] == 'file_size'
@pro_resource = Attachment.where(:container_type => 'Project').order("filesize desc")
elsif params[:sort] == 'file_upload'
@pro_resource = Attachment.where(:container_type => 'Project').order("created_on desc")
elsif params[:sort] == 'file_download_times'
@pro_resource = Attachment.where(:container_type => 'Project').order("downloads desc")
else
@pro_resource = Attachment.where(:container_type => 'Project').order("created_on desc")
end
@pro_resource = paginateHelper @pro_resource,30 @pro_resource = paginateHelper @pro_resource,30
@page = (params['page'] || 1).to_i - 1 @page = (params['page'] || 1).to_i - 1
@ -88,9 +112,9 @@ class AdminController < ApplicationController
case params[:format] case params[:format]
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15}) @offset, @limit = api_offset_and_limit({:limit => 50})
else else
@limit = 15#per_page_option @limit = 50 #per_page_option
end end
@status = params[:status] || 1 @status = params[:status] || 1
@ -370,7 +394,13 @@ class AdminController < ApplicationController
#组织 #组织
def organization def organization
@organizations = Organization.all @organizations = Organization.find_by_sql("SELECT * FROM organizations ORDER BY created_at DESC")
#@organizations = Organization.all.order("created_at desc")
@organization_count = @organizations.count
@organization_pages = Paginator.new @organization_count, 30, params['page'] || 1
@organizations = paginateHelper @organizations,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format| respond_to do |format|
format.html format.html
end end
@ -378,17 +408,14 @@ class AdminController < ApplicationController
#学校列表 #学校列表
def schools def schools
@school_name = params[:school_name]
if @school_name && @school_name != '' @schools = School.find_by_sql("SELECT * FROM schools ORDER BY created_at DESC")
@schools = School.where("name like '%#{@school_name}%'")
elsif @school_name.nil?
@schools = []
else @school_name && @school_name == ' '
@schools = School.where('1=1')
end
@school_count = @schools.count @school_count = @schools.count
@school_pages = Paginator.new @school_count, 100, params['page'] || 1
@schools = paginateHelper @schools,100 @school_pages = Paginator.new @school_count, 30, params['page'] || 1
@schools = paginateHelper @schools,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format| respond_to do |format|
format.html format.html
end end

@ -8,6 +8,15 @@ class AtController < ApplicationController
users = find_at_users(params[:type], params[:id]) users = find_at_users(params[:type], params[:id])
@users = users @users = users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users @users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
#加上all
if @users.size > 0
allUser = Struct.new(:id, :name).new
allUser.id = @users.map{|u| u.id}.join(",")
allUser.name = "all"
@users.insert(0, allUser)
end
@users
end end
private private

@ -103,6 +103,9 @@ class AttachmentsController < ApplicationController
direct_download_history direct_download_history
end end
else else
# 记录用户行为
record_user_actions(params[:id])
# 直接下载历史版本
direct_download_history direct_download_history
end end
end end
@ -113,6 +116,14 @@ class AttachmentsController < ApplicationController
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end end
def record_user_actions id
if params[:action] == "download_history"
UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) unless id.nil?
elsif params[:action] == "download"
UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id) unless id.nil?
end
end
def download def download
# modify by nwb # modify by nwb
# 下载添加权限设置 # 下载添加权限设置
@ -135,6 +146,8 @@ class AttachmentsController < ApplicationController
direct_download direct_download
end end
else else
# 记录用户行为
record_user_actions(params[:id])
direct_download direct_download
end end
end end

@ -7,6 +7,7 @@ class CoursesController < ApplicationController
helper :members helper :members
helper :words helper :words
helper :attachments helper :attachments
helper :files
helper :activity_notifys helper :activity_notifys
before_filter :auth_login1, :only => [:show, :course_activity, :feedback] before_filter :auth_login1, :only => [:show, :course_activity, :feedback]

@ -207,8 +207,7 @@ class FilesController < ApplicationController
sort = "created_on DESC" sort = "created_on DESC"
end end
if keywords != "%%" if keywords != "%%"
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%"). resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
reorder(sort)
else else
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort) resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
end end

@ -17,9 +17,9 @@ class HomeworkCommonController < ApplicationController
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
if @is_teacher if @is_teacher
@homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10) @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
else else
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10) @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
end end
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@is_new = params[:is_new] @is_new = params[:is_new]
@ -51,10 +51,16 @@ class HomeworkCommonController < ApplicationController
@user = User.current @user = User.current
@is_in_course = params[:is_in_course].to_i @is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i @course_activity = params[:course_activity].to_i
if @is_in_course == 1 || @course_activity == 1
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
else
respond_to do |format| respond_to do |format|
format.html{render :layout => 'new_base_user'} format.html{render :layout => 'new_base_user'}
end end
end end
end
def update def update
if params[:homework_common] if params[:homework_common]

@ -225,7 +225,7 @@ class OrganizationsController < ApplicationController
condition = "%#{params[:name].strip}%".gsub(" ","") condition = "%#{params[:name].strip}%".gsub(" ","")
end end
sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+ sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})" "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0"
#user_courses = Course.find_by_sql(sql) #user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql) @courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id) # @added_course_ids = @organization.courses.map(&:id)
@ -269,7 +269,7 @@ class OrganizationsController < ApplicationController
condition = "%#{params[:name].strip}%".gsub(" ","") condition = "%#{params[:name].strip}%".gsub(" ","")
end end
sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" + sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})" " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1"
#user_projects = Course.find_by_sql(sql) #user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql) @projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id) # @added_course_ids = @organization.projects.map(&:id)

@ -1,3 +1,4 @@
#encoding: utf-8
class StudentWorkController < ApplicationController class StudentWorkController < ApplicationController
layout "base_courses" layout "base_courses"
include StudentWorkHelper include StudentWorkHelper
@ -62,6 +63,13 @@ class StudentWorkController < ApplicationController
homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0 homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0
end end
end end
#修改作品提示消息更新
student_work_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, StudentWork.name, 0)
student_work_messages.each do |message|
message.update_attribute(:viewed, true)
end
# 作品打分消息状态更新 # 作品打分消息状态更新
studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0) studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0)
studentworks_scores.each do |studentworks_score| studentworks_scores.each do |studentworks_score|
@ -282,7 +290,7 @@ class StudentWorkController < ApplicationController
@submit_result = true @submit_result = true
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id] student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
student_work ||= StudentWork.new student_work ||= StudentWork.new
student_work.name = params[:student_work][:name] student_work.name = params[:student_work][:name] == "#{@homework.name}的作品提交(可修改)" ? "#{@homework.name}的作品提交" : params[:student_work][:name]
student_work.description = params[:student_work][:description] student_work.description = params[:student_work][:description]
student_work.homework_common_id = @homework.id student_work.homework_common_id = @homework.id
student_work.user_id = User.current.id student_work.user_id = User.current.id
@ -368,6 +376,8 @@ class StudentWorkController < ApplicationController
@work.save_attachments(params[:attachments]) @work.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@work) render_attachment_warning_if_needed(@work)
if @work.save if @work.save
#如果学生作品被打分后修改,应该给老师提示
send_message_to_teacher(@work)
if @homework.homework_type == 3 if @homework.homework_type == 3
@student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first @student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first
student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0) student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0)

@ -573,7 +573,7 @@ class UsersController < ApplicationController
@r_sort = @b_sort == "desc" ? "asc" : "desc" @r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current @user = User.current
search = params[:name].to_s.strip.downcase search = params[:name].to_s.strip.downcase
type_ids = params[:property] ? "(" + params[:property] + ")" : "(1, 2, 3)" type_ids = params[:property]=="" || params[:property].nil? ? "(1, 2, 3)" : "(" + params[:property] + ")"
if(params[:type].blank? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@ -717,6 +717,7 @@ class UsersController < ApplicationController
end end
student_work.save student_work.save
send_message_to_teacher(student_work)
homework.update_attributes(:updated_at => Time.now) homework.update_attributes(:updated_at => Time.now)
update_course_activity(homework.class,homework.id) update_course_activity(homework.class,homework.id)
update_user_activity(homework.class,homework.id) update_user_activity(homework.class,homework.id)
@ -2473,13 +2474,13 @@ class UsersController < ApplicationController
# 资源库 分为全部 课程资源 项目资源 附件 # 资源库 分为全部 课程资源 项目资源 附件
def user_resource def user_resource
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
# 别人的资源库是没有权限去看的 # 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i if User.current.id.to_i != params[:id].to_i
render_403 render_403
return return
end end
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
@ -2533,6 +2534,8 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
@user = User.find(params[:id]) @user = User.find(params[:id])
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc" @score = @b_sort == "desc" ? "asc" : "desc"
@ -2561,16 +2564,18 @@ class UsersController < ApplicationController
end end
def import_resources_search def import_resources_search
if User.current.id.to_i != params[:id].to_i
render_403
return
end
@resource_id = params[:mul_id]
@resource_type = params[:mul_type]
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc" @score = @b_sort == "desc" ? "asc" : "desc"
@user = User.current @user = User.current
@switch_search = params[:name].nil? ? " " : params[:name] @switch_search = params[:name].nil? ? " " : params[:name]
search = "%#{@switch_search.strip.downcase}%" search = "%#{@switch_search.strip.downcase}%"
# 别人的资源库是没有权限去看的 # 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i
render_403
return
end
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}

@ -2137,6 +2137,20 @@ module ApplicationHelper
end end
#如果学生作品被打分后修改,应该给老师提示
def send_message_to_teacher student_work
if StudentWork === student_work
if student_work.student_works_scores.any?
course = student_work.homework_common.course
course.members.map(&:user_id).uniq.each do|user_id|
if User.find(user_id).allowed_to?(:as_teacher, course)
student_work.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course.id, :viewed => false, :status => 1)
end
end
end
end
end
private private
def wiki_helper def wiki_helper

@ -865,7 +865,7 @@ module CoursesHelper
# 学生按作业总分排序取前8个 # 学生按作业总分排序取前8个
def hero_homework_score(course, score_sort_by) def hero_homework_score(course, score_sort_by)
sql_select = "SELECT members.*,( sql_select = "SELECT members.*,(
SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)) SELECT SUM(IF(student_works.final_score is null,null,IF(student_works.final_score = 0, 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{course.id} AND homework_commons.course_id = #{course.id}

@ -1,2 +1,15 @@
module SchoolHelper module SchoolHelper
def schoolMember_num school
count = student_num(school) + teacher_num(school)
count.to_s
end
def student_num school
UserExtensions.find_by_sql("SELECT * FROM user_extensions WHERE occupation = '#{school.name}' AND identity = '1'").count
end
def teacher_num school
UserExtensions.find_by_sql("SELECT * FROM user_extensions AS ue, schools AS s WHERE ue.school_id = s.id AND s.name = '#{school.name}' AND ue.identity = '0'").count
end
end end

@ -62,7 +62,7 @@ module UsersHelper
when 'Course' when 'Course'
result = current_time_and_term_resource content result = current_time_and_term_resource content
when 'Project' when 'Project'
result = content.name + "(" + content.id.to_s + ")" result = content.name
when 'Issue' when 'Issue'
result = content.subject result = content.subject
when 'Message' when 'Message'

@ -66,8 +66,8 @@ class CourseActivity < ActiveRecord::Base
# 发布新课导语 # 发布新课导语
# 导语要放置在课程创建信息之后 # 导语要放置在课程创建信息之后
# 导语
def add_course_lead def add_course_lead
# 避免空数据迁移报错问题
if self.course_act_type == "Course" and Message.where("id=12440").any? if self.course_act_type == "Course" and Message.where("id=12440").any?
lead_message = Message.find(12440) lead_message = Message.find(12440)
name = lead_message.subject name = lead_message.subject
@ -75,7 +75,7 @@ class CourseActivity < ActiveRecord::Base
# message的status状态为0为正常为1表示创建课程时发送的message # message的status状态为0为正常为1表示创建课程时发送的message
# author_id 默认为课程使者创建 # author_id 默认为课程使者创建
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true ) message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true )
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一 # 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first
end end
end end

@ -84,7 +84,9 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal attr_reader :current_journal
# fq # fq
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message, :add_issues_count after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message,
act_as_at_message(:description, :author_id), :add_issues_count
after_update :be_user_score,:update_activity after_update :be_user_score,:update_activity
after_destroy :down_user_score, :decrease_issues_count after_destroy :down_user_score, :decrease_issues_count
# after_create :be_user_score # after_create :be_user_score
@ -165,12 +167,12 @@ class Issue < ActiveRecord::Base
end end
# at 功能添加消息提醒 # at 功能添加消息提醒
def act_as_at_message # def act_as_at_message
users = self.description.scan /<span class="at" data-user-id="(\d+?)">/m # users = self.description.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid| # users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) # self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
end # end
end # end
# 创建issue的时候issues_count加1 # 创建issue的时候issues_count加1
def add_issues_count def add_issues_count

@ -51,7 +51,7 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes, :add_journals_count before_create :split_private_notes, :add_journals_count
# fq # fq
after_save :act_as_activity,:be_user_score, :act_as_forge_message, :act_as_at_message after_save :act_as_activity,:be_user_score, :act_as_forge_message, act_as_at_message(:notes, :user_id)
after_create :update_issue_time after_create :update_issue_time
# end # end
#after_destroy :down_user_score #after_destroy :down_user_score
@ -186,13 +186,6 @@ class Journal < ActiveRecord::Base
end end
end end
def act_as_at_message
users = self.notes.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id)
end
end
# 更新用户分数 -by zjc # 更新用户分数 -by zjc
def be_user_score def be_user_score
#新建了缺陷留言且留言不为空,不为空白 #新建了缺陷留言且留言不为空,不为空白

@ -68,7 +68,9 @@ class JournalsForMessage < ActiveRecord::Base
has_many :at_messages, as: :at_message, dependent: :destroy has_many :at_messages, as: :at_message, dependent: :destroy
validates :notes, presence: true, if: :is_homework_jour? validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score after_create :act_as_activity, :act_as_course_activity, :act_as_course_message,
act_as_at_message(:notes, :user_id), :act_as_user_feedback_message,
:act_as_principal_activity, :act_as_student_score
after_create :reset_counters! after_create :reset_counters!
#after_update :update_activity #after_update :update_activity
after_destroy :reset_counters! after_destroy :reset_counters!
@ -253,12 +255,7 @@ class JournalsForMessage < ActiveRecord::Base
end end
end end
def act_as_at_message
users = self.notes.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id)
end
end
# 用户留言消息通知 # 用户留言消息通知
def act_as_user_feedback_message def act_as_user_feedback_message
# 主留言 # 主留言

@ -81,7 +81,8 @@ class Message < ActiveRecord::Base
after_update :update_messages_board, :update_activity after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity,
:act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id)
#before_save :be_user_score #before_save :be_user_score
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
@ -287,13 +288,6 @@ class Message < ActiveRecord::Base
end end
end end
def act_as_at_message
users = self.content.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
end
end
#更新用户分数 -by zjc #更新用户分数 -by zjc
def be_user_score def be_user_score
#新建message且无parent的为发帖 #新建message且无parent的为发帖

@ -42,9 +42,9 @@ class Principal < ActiveRecord::Base
if q.blank? if q.blank?
where({}) where({})
else else
pattern = "%#{q}%" pattern = "%#{q}%".gsub("/","//").gsub("_","/_")
# sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ") # sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ")
sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p)" sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p) escape '/'"
params = {:p => pattern} params = {:p => pattern}
if q =~ /^(.+)\s+(.+)$/ if q =~ /^(.+)\s+(.+)$/
a, b = "#{$1}%", "#{$2}%" a, b = "#{$1}%", "#{$2}%"

@ -0,0 +1,4 @@
class UserActions < ActiveRecord::Base
attr_accessible :action_id, :action_type, :user_id
has_many :users
end

@ -10,16 +10,16 @@
资源名称 资源名称
</th> </th>
<th style="width: 30px;"> <th style="width: 30px;">
资源大小 <%= link_to "资源大小",admin_course_resource_list_path(:sort => "file_size") %>
</th> </th>
<th style="width: 25px;"> <th style="width: 25px;">
资源类型 资源类型
</th> </th>
<th style="width: 23px;"> <th style="width: 23px;">
上传时间 <%= link_to "上传时间",admin_course_resource_list_path(:sort => "file_upload") %>
</th> </th>
<th style="width: 15px;"> <th style="width: 15px;">
下载次数 <%= link_to "下载次数",admin_course_resource_list_path(:sort => "file_download_times") %>
</th> </th>
<th style="width: 20px;"> <th style="width: 20px;">
上传者 上传者
@ -62,3 +62,5 @@
<div class="pagination"> <div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %> <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div> </div>
<% html_title(l(:label_course_resource_list)) -%>

@ -73,4 +73,8 @@
</table> </table>
</div> </div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_course_all)) -%> <% html_title(l(:label_course_all)) -%>

@ -73,3 +73,5 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<% html_title(l(:label_excellent_courses_list)) -%>

@ -45,6 +45,9 @@
<th style="width: 50px;"> <th style="width: 50px;">
用户身份 用户身份
</th> </th>
<th style="width: 50px;">
用户单位
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -74,6 +77,9 @@
<td align="center"> <td align="center">
老师 老师
</td> </td>
<td align="center">
<%= teacher.school_id.nil? ? "" : (School.find teacher.school_id).try(:name) %>
</td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -82,3 +88,5 @@
<div class="pagination"> <div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %> <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div> </div>
<% html_title(l(:label_latest_login_teacher_list)) -%>

@ -46,6 +46,9 @@
<th style="width: 50px;"> <th style="width: 50px;">
用户身份 用户身份
</th> </th>
<th style="width: 50px;">
用户单位
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -88,6 +91,17 @@
<% end %> <% end %>
<% end%> <% end%>
</td> </td>
<td align="center">
<% unless user.user_extensions.nil? %>
<% if user.user_extensions.identity.to_i == 0 %>
<!--优先取school中校名如果校名不存在就取occupation-->
<% occupation = user.user_extensions.school_id.nil? ? "" : (School.where("id =?", user.user_extensions.school_id)).first.try(:name) %>
<%= occupation.blank? ? user.user_extensions.occupation : occupation %>
<% else %>
<%= user.user_extensions.occupation %>
<% end %>
<% end %>
</td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

@ -40,4 +40,8 @@
</table> </table>
</div> </div>
<% html_title(l(:label_project_plural)) -%> <ul class="wlist" id="pages" style="float: right;margin-top: 10px;">
<%= pagination_links_full @organization_pages, @organization_count ,:per_page_links => true, :remote => false, :flag => true %>
</ul>
<!% html_title(l(:llabel_organization_list)) -%>

@ -10,16 +10,16 @@
资源名称 资源名称
</th> </th>
<th style="width: 30px;"> <th style="width: 30px;">
资源大小 <%= link_to "资源大小",admin_project_resource_list_path(:sort => "file_size") %>
</th> </th>
<th style="width: 25px;"> <th style="width: 25px;">
资源类型 资源类型
</th> </th>
<th style="width: 23px;"> <th style="width: 23px;">
上传时间 <%= link_to "上传时间",admin_project_resource_list_path(:sort => "file_upload") %>
</th> </th>
<th style="width: 15px;"> <th style="width: 15px;">
下载次数 <%= link_to "下载次数",admin_project_resource_list_path(:sort => "file_download_times") %>
</th> </th>
<th style="width: 20px;"> <th style="width: 20px;">
上传者 上传者
@ -62,3 +62,5 @@
<div class="pagination"> <div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %> <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div> </div>
<% html_title(l(:label_project_resource_list)) -%>

@ -73,6 +73,10 @@
</table> </table>
</div> </div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_project_plural)) -%> <% html_title(l(:label_project_plural)) -%>
<script> <script>

@ -1,43 +1,64 @@
<h3 style="float: left"> <h3 style="float: left">
<%=l(:label_school_plural)%> <%=l(:label_school_plural)%>
</h3> </h3>
<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %> <!--<!%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>-->
<%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%> <!-- <!%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>-->
<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>"> <!--<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>">-->
<% end %> <!% end %>
<div class="cl"></div> <div class="cl"></div>
<div class="autoscroll" style="margin-top: 40px;"> <div class="autoscroll" style="margin-top: 40px;">
<table class="list" style="width: 100%;table-layout: fixed"> <table class="list" style="width: 100%;table-layout: fixed">
<thead> <thead>
<tr> <tr>
<th style="width: 50px;"> <th style="width: 35px;">
序号 序号
</th> </th>
<th style="width: 100px;"> <th style="width: 60px;">
LOGO LOGO
</th> </th>
<th> <th style="width: 100px;">
学校名称 学校名称
</th> </th>
<th style="width: 100px;"></th> <th style="width: 35px;">
用户数
</th>
<th style="width: 90px;">
创建时间
</th>
<th style="width: 80px;">
编辑高校信息
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @count=@page * 30 %>
<% @schools.each do |school| %> <% @schools.each do |school| %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td style="text-align:center;vertical-align: middle;"> <!td style="text-align:center;vertical-align: middle;">
<%= school.id %> <!%= school.id %>
<% @count +=1 %>
<td align="center">
<%=@count %>
</td> </td>
<td align="center"> <td align="center">
<%= image_tag(school.logo_link,width:40,height:40) %> <%= image_tag(school.logo_link,width:40,height:40) %>
<!%= school.name %>
</td> </td>
<td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=school.name%>'> <td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=school.name%>'>
<span> <span>
<%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %> <%= link_to school.name,"http://#{Setting.host_name}/?school_id=#{school.id}" %>
</span> </span>
</td> </td>
<td class="buttons" style="vertical-align: middle;"> <td style="vertical-align: middle;text-align:center">
<%= schoolMember_num(school) %>
</td>
<td style="vertical-align: middle;text-align:center">
<%= format_time(school.created_at) %>
</td>
<td class="buttons" style="vertical-align: middle;text-align:center">
<%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %> <%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
<%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> <%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
</td> </td>
@ -50,4 +71,4 @@
<%= pagination_links_full @school_pages, @school_count ,:per_page_links => true, :remote => false, :flag => true %> <%= pagination_links_full @school_pages, @school_count ,:per_page_links => true, :remote => false, :flag => true %>
</ul> </ul>
<% html_title(l(:label_project_plural)) -%> <% html_title(l(:label_school_plural)) -%>

@ -40,7 +40,10 @@
<%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %>
<%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %>
<%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %>
<th style="width: 100px;"></th> <%#= sort_header_tag('user_occupation', :caption => l(:field_occupation), :default_order => 'desc') %>
<th style="width: 100px;">用户单位</th>
<th style="width: 40px;"></th>
<th style="width: 40px;"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -53,8 +56,11 @@
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center"><%= checked_image user.admin? %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center"><%= checked_image user.admin? %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="created_on" align="center" title='<%=format_time(user.created_on)%>'><%= format_time(user.created_on) %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="created_on" align="center" title='<%=format_time(user.created_on)%>'><%= format_time(user.created_on) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="last_login_on" align="center" title='<%= format_time(user.last_login_on)%>'><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="last_login_on" align="center" title='<%= format_time(user.last_login_on)%>'><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
<td class="buttons"> <%= change_status_link(user) %> <% occupation = user.user_extensions.identity == 0 ? School.where("id=?",user.user_extensions.school_id).first.try(:name) : user.user_extensions.occupation %>
<%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> </td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center" title="<%= occupation %>"> <%= truncate( occupation, :length => 12 ) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= change_status_link(user) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %></td>
</tr> </tr>
<% end -%> <% end -%>
</tbody> </tbody>

@ -1,6 +1,11 @@
[ [
<% @users && @users.each_with_index do |person,index| %> <% @users && @users.each_with_index do |person,index| %>
<% if index == 0 %>
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% else %>
{"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"} {"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
<%= index != @users.size-1 ? ',' : '' %> <%= index != @users.size-1 ? ',' : '' %>
<% end %> <% end %>
<% end %>
] ]

@ -8,11 +8,11 @@
<div class="fl"> <div class="fl">
<p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p> <p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p>
<p class="f12"> <p class="f12">
<% if e_course.attachments.count > 0 %> <% if visable_attachemnts_incourse(e_course).count > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)</span> <span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts_incourse(e_course).count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% end %> <% end %>
<% if e_course.homework_commons.count > 0 %> <% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span> <span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</p> </p>

@ -108,16 +108,8 @@
<div class="cl"></div> <div class="cl"></div>
<div class="re_con_top"> <div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p> <p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080"> <p class="f_r" style="color: #808080" id="course_filter_order">
<% if @order == "asc" %> <%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>
</p> </p>
</div> </div>
</div> </div>

@ -0,0 +1,15 @@
<% if @order == "asc" %>
按&nbsp;<%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey",:remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey" , :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey", :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort =>"quotes:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q),:class => "f_b c_grey", :remote => true %>
<%= render partial:'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>

@ -0,0 +1,9 @@
<% if @order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort => "created_on:desc", :order => order,:tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort => "downloads:desc", :order => order,:tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort => "quotes:desc", :order => order,:tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort => "created_on:asc", :order => order, :tag_name => tag_name,:name => search_name),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort => "downloads:asc", :order => order, :tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort =>"quotes:asc", :order => order, :tag_name => tag_name,:name => search_name),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>

@ -56,16 +56,8 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= User.current.member_of_org?(@org_subfield.organization) ? @all_attachments.count : @all_attachments.select{|attach| attach.is_public == 1 }.count %></span>&nbsp;个资源</p> <p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= User.current.member_of_org?(@org_subfield.organization) ? @all_attachments.count : @all_attachments.select{|attach| attach.is_public == 1 }.count %></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080"> <p class="f_r" style="color: #808080" id="org_sort">
<% if @order == "asc" %> <%= render :partial => 'files/org_order_filter', :locals => {:order => @order, :sort => @sort, :tag_name => @tag_name, :search_name => nil} %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>
</p> </p>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

@ -5,4 +5,6 @@
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list', $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list',
:locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>"); :locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count %>"); $("#attachment_count").html("<%= @result.count %>");
$("#org_sort").html("<%= escape_javascript(render :partial => 'org_order_filter',
:locals => {:sort => @sort, :order => @order, :tag_name => @tag_name, :search_name => @q}) %>");
<% end %> <% end %>

@ -1,3 +1,5 @@
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list', $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list',
:locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>"); :locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>");
$("#attachment_count").html("<%= @result.count %>"); $("#attachment_count").html("<%= @result.count %>");
$("#org_sort").html("<%= escape_javascript(render :partial => 'org_order_filter',
:locals => {:sort => @sort, :order => @order, :tag_name => @tag_name,:search_name => @q}) %>");

@ -1,5 +1,6 @@
<% if @course %> <% if @course %>
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>"); $("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>");
$("#attachment_count").html("<%= @result.count%>") $("#attachment_count").html("<%= @result.count%>")
<% else %> <% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>"); $("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>");

@ -1,4 +1,10 @@
<script type="text/javascript"> <script type="text/javascript">
<% if @is_in_course == 1 || @course_activity == 1 %>
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
<% end %>
function reset_homework(){ function reset_homework(){
$("#homework_name").val(""); $("#homework_name").val("");
$("#homework_publish_time").val(""); $("#homework_publish_time").val("");
@ -24,7 +30,7 @@
<% end %> <% end %>
} }
</script> </script>
<div class="homepageRightBanner mb10"> <div class="homepageRightBanner mb10 <%= (@is_in_course == 1 || @course_activity == 1) ? 'ml10' : '' %>">
<div class="NewsBannerName">编辑作业</div> <div class="NewsBannerName">编辑作业</div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

@ -9,7 +9,8 @@
$(function(){ $(function(){
$("#RSide").removeAttr("id"); $("#RSide").removeAttr("id");
$("#Container").css("width","1000px"); $("#Container").css("width","1000px");
if(<%= @is_edit %>) { is_edit = <%= @is_edit.present? && @is_edit == true %>
if(is_edit) {
issueEditShow(); issueEditShow();
} }
}); });

@ -90,8 +90,8 @@
<% end%> <% end%>
</div> </div>
<!--<div class="orgName fl mb5 f14">组织id<%#= @organization.id %></div>--> <!--<div class="orgName fl mb5 f14">组织id<%#= @organization.id %></div>-->
<div class="orgName fl mb5 f14"> <div class="orgName fl mb5 f14" title="<%= @organization.name %>">
<%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> <%= link_to truncate(@organization.name,:length => 26), organization_path(@organization.id), :class=>"pr_info_name c_dark fb break_word" %>
<% if User.current.logged? %> <% if User.current.logged? %>
<% if @organization.is_public? %> <% if @organization.is_public? %>
<span class="img_private"><%= l(:label_public)%></span> <span class="img_private"><%= l(:label_public)%></span>

@ -32,7 +32,10 @@
location.href = document.referrer; location.href = document.referrer;
} }
</script> </script>
<div class="resources" nhname="new_topic_form"> <div class="homepageRightBanner" style="margin-top:<%= User.current.logged? ? '0px':'10px' %>; margin-bottom:10px;">
<div class="NewsBannerName"><%= OrgSubfield.try(:find, params[:field_id]).try(:name) %></div>
</div>
<div class="resources" nhname="new_topic_form" style="padding-top:<%= params[:field_id].present? ? '0px': '15px' %>">
<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %> <%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
<div> <div>
<textarea class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题"></textarea> <textarea class="postDetailInput fl mr15" style="margin-bottom:15px;" name="org_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#org_document_editor').show();" placeholder="请输入文章标题"></textarea>

@ -63,7 +63,7 @@
</div> </div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>"> <div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>">
<ul > <ul >
<%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.where("is_delete=0").reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul> </ul>
</div> </div>
</div> </div>
@ -77,7 +77,7 @@
</div> </div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>"> <div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul> <ul>
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.where("status=1").reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul> </ul>
</div> </div>
</div> </div>

@ -10,6 +10,9 @@
TO&nbsp;&nbsp;<%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %> TO&nbsp;&nbsp;<%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %>
| |
<span style="color:#269ac9;"><%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %></span> <span style="color:#269ac9;"><%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %></span>
<% if @organization.home_id == document.id %>
<span class="red_homework_btn_cir ml5">已设为首页</span>
<% end %>
</div> </div>
<div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div> <div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div>
<div class="homepagePostDate fl"> <div class="homepagePostDate fl">

@ -19,8 +19,11 @@
'<%= check_uniq_organizations_path%>'+'?org_name='+$("#organization_name").val().trim()+"&config_page=Y" + "&org_id="+id '<%= check_uniq_organizations_path%>'+'?org_name='+$("#organization_name").val().trim()+"&config_page=Y" + "&org_id="+id
) )
} }
function update_org(id){ function update_org(id, old_value, input_value){
if (old_value == input_value)
{
check_uniq(id); check_uniq(id);
}
if( $checkName){ if( $checkName){
$("#edit_organization_"+id).submit(); $("#edit_organization_"+id).submit();
} }
@ -77,7 +80,7 @@
&nbsp;<span>允许游客下载</span> &nbsp;<span>允许游客下载</span>
<span class="c_green f12" id="allow_down_hint"><%= @organization.is_public? ? "" : "(私有组织不允许游客下载资源)" %></span> <span class="c_green f12" id="allow_down_hint"><%= @organization.is_public? ? "" : "(私有组织不允许游客下载资源)" %></span>
</div> </div>
<a href="javascript:void(0);" class="saveBtn ml80 db fl" onclick="update_org(<%=@organization.id %>);">保存</a> <a href="javascript:void(0);" class="saveBtn ml80 db fl" onclick="update_org('<%=@organization.id %>','<%= @organization.name %>', $('#organization_name'));">保存</a>
<% end %> <% end %>
</div> </div>
<div class="undis ml15 mr15" id="orgContent_2"> <div class="undis ml15 mr15" id="orgContent_2">

@ -46,8 +46,8 @@
<% end%> <% end%>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
<% if !@is_evaluation && !@is_teacher %> <% if !@is_evaluation && (!@is_teacher || params[:show_work_id].present?) %>
<% work=@homework.student_works.where("user_id = ?",User.current.id).first %> <% work= params[:show_work_id].nil? ? @homework.student_works.where("user_id = ?",User.current.id).first : StudentWork.find(params[:show_work_id]) %>
<% unless work.nil? %> <% unless work.nil? %>
<% if @homework.homework_type == 2 %> <% if @homework.homework_type == 2 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");

@ -79,10 +79,6 @@
} }
} }
var KE = {
MDU: "1234455",//当前文章标识符
};
function nh_check_field(params){ function nh_check_field(params){
var result=true; var result=true;
if(!regexStudentWorkName()) { if(!regexStudentWorkName()) {
@ -90,14 +86,14 @@
return result; return result;
} }
if(params.content!=undefined){ if(params.content!=undefined){
if(params.content.isEmpty()){ if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
result=false; result=false;
} }
if(params.content.html()!=params.textarea.html() || params.issubmit==true){ if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html()); params.textarea.html(params.content.html());
params.content.sync(); params.content.sync();
if(params.content.isEmpty()){ if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
params.contentmsg.html('作品描述不能为空'); params.contentmsg.html('作品描述不能为空');
}else{ }else{
params.contentmsg.html(''); params.contentmsg.html('');
@ -150,6 +146,17 @@
edit.iframe.height(150); edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150)); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
}, },
afterBlur:function(){
if(this.isEmpty()) {
this.edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
}
},
afterFocus: function(){
var edit = this.edit;
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
edit.html('');
}
},
afterCreate:function(){ afterCreate:function(){
//init //init
var edit = this.edit; var edit = this.edit;
@ -159,7 +166,7 @@
//reset height //reset height
var edit = this.edit; var edit = this.edit;
var body = edit.doc.body; var body = edit.doc.body;
edit.html(params.textarea.innerHTML); edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
//paramsHeight = params.kindutil.removeUnit(this.height); //paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150); edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
@ -242,7 +249,7 @@
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
<% end %> <% end %>
<div> <div>
<%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称",:value=>"#{@homework.name}的作品提交", :onkeyup => "regexStudentWorkName();" %> <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称",:value=>"#{@homework.name}的作品提交(可修改)", :onkeyup => "regexStudentWorkName();" %>
<div class="cl"></div> <div class="cl"></div>
<p id="student_work_name_span" class="c_red mb10"></p> <p id="student_work_name_span" class="c_red mb10"></p>
</div> </div>

@ -41,14 +41,6 @@
<% content = activity.parent.content%> <% content = activity.parent.content%>
<% end %> <% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %> <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
<% if activity.status == 1 %>
<span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.year %></span>
<span style="font-size:10.5000pt;">年</span>
<span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.month %></span>
<span style="font-size:10.5000pt;">月</span>
<span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.day %></span>
<span style="font-size:10.5000pt;">日</span>
<% end %>
<div class="cl"></div> <div class="cl"></div>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div> <div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div> <div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>

@ -25,9 +25,9 @@
<% end%> <% end%>
</li> </li>
<li class="fl subject-list-date"> <li class="fl subject-list-date">
<%= link_to "发布时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "fl",:remote => true%> <%= link_to "发布时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort),:class => "fl",:remote => true%>
<% if @order == "created_at"%> <% if @order == "publish_time"%>
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%> <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%>
<% end%> <% end%>
</li> </li>
</ul> </ul>

@ -27,7 +27,7 @@
<a href="<%= import_resources_user_path(User.current, :type => '1', :subfield_file_id => params[:subfield_file_id]) %>" id="my_resources_choose" class="subject-choose fl" data-remote="true">我的资源</a> <a href="<%= import_resources_user_path(User.current, :type => '1', :subfield_file_id => params[:subfield_file_id]) %>" id="my_resources_choose" class="subject-choose fl" data-remote="true">我的资源</a>
<% end %> <% end %>
<div id="user_import_resource_search"> <div id="user_import_resource_search">
<%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => ''} %> <%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => '', :mul_id => @resource_id, :mul_type => @resource_type} %>
</div> </div>
<!--<%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id), :remote => true , :method => 'get', :id => 'resource_search_form') do %>--> <!--<%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id), :remote => true , :method => 'get', :id => 'resource_search_form') do %>-->
<!--<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />--> <!--<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="subjectSearch fr" />-->

@ -194,9 +194,10 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="mt10 <%= defined?(select_course) ? 'none' : ''%>"> <!--<div class="mt10 <%= defined?(select_course) ? 'none' : ''%>">
<%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %> <%#= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %>
</div> </div>-->
<%= hidden_field_tag :course_id, params[:course_id], :value =>homework.course_id %>
<p id="homework_course_id_span" class="c_red mt5"></p> <p id="homework_course_id_span" class="c_red mt5"></p>
<p id="e_tip" class="c_grey"></p> <p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p> <p id="e_tips" class="c_grey"></p>

@ -1,6 +1,6 @@
<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container', <%= form_tag( url_for({:controller => 'users', :action => 'import_into_container',
:mul_id => project_id.nil? ? (course_id.nil? ? subfield_file_id : course_id) : project_id, :mul_id => @resource_id,
:mul_type => project_id.nil? ? (course_id.nil? ? "SubfieldFile" : "Course") : "Project"}), :mul_type => @resource_type}),
:method => 'post', :id => 'resource_import_container_form') do %> :method => 'post', :id => 'resource_import_container_form') do %>
<% @attachments.each do |attach| %> <% @attachments.each do |attach| %>
<ul class="subjectRow"> <ul class="subjectRow">

@ -9,7 +9,7 @@
} }
lastSearchCondition = $(e.target).val().trim(); lastSearchCondition = $(e.target).val().trim();
$.ajax({ $.ajax({
url: '<%= url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id) %>'+'?name='+ e.target.value+'&type=<%=type %>', url: '<%= url_for({:controller => 'users', :action => 'import_resources_search', :id => User.current.id}) %>'+'?name='+ e.target.value+'&type=<%=type %>'+'&mul_id=<%=@resource_id %>'+'&mul_type=<%=@resource_type %>',
type:'get' type:'get'
}); });
} }

@ -370,7 +370,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">回复了作品评论:</span> <span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">回复了作品评论:</span>
</li> </li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey"> <li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<!--:onmouseover => "message_titile_show($(this),event)",--> <!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>--> <!--:onmouseout => "message_titile_hide($(this))" %>-->
</a> </a>
@ -424,6 +424,28 @@
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li> <li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul> </ul>
<% end %> <% end %>
<% if ma.course_message_type == "StudentWork" && ma.status == 1 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a>
</li>
<li class="homepageNewsPubType fl">
<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "同学",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">重新提交了作品:</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.homework_common_id, :show_work_id => ma.course_message_id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
<%#= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}" %>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!-- 创建课程消息 --> <!-- 创建课程消息 -->
<% if ma.course_message_type == "Course" %> <% if ma.course_message_type == "Course" %>
<ul class="homepageNewsList fl"> <ul class="homepageNewsList fl">

@ -1,9 +1,9 @@
<% if params[:project_id] %> <% if params[:project_id] %>
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id]} ) %>'); $('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
<% elsif params[:course_id] %> <% elsif params[:course_id] %>
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id]} ) %>'); $('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
<% elsif params[:subfield_file_id] %> <% elsif params[:subfield_file_id] %>
$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id]} ) %>'); $('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
<% end %> <% end %>
showModal('ajax-modal', '615px'); showModal('ajax-modal', '615px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();

@ -1,3 +1,5 @@
$("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list', $("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list',
:locals => {:user => @user, :type => @type, :project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} ) %>'); :locals => {:user => @user, :type => @type,
:mul_id => @resource_id,
:mul_type => @resource_type}) %>');
$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');

@ -1,2 +1,2 @@
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type} )%>"); $("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} )%>");

@ -58,7 +58,7 @@
</ul> </ul>
<div class="cl"></div> <div class="cl"></div>
<div id="homework_search_input" class="mt10 fl"> <div id="homework_search_input" class="mt10 fl">
<%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %> <%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => nil} %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="w683 fl mr10 mt10" id="homework_repository_list"> <div class="w683 fl mr10 mt10" id="homework_repository_list">

@ -1,8 +1,8 @@
I18n.default_locale = 'en' I18n.default_locale = 'en'
I18n.backend = Redmine::I18n::Backend.new I18n.backend = Redmine::I18n::Backend.new
require 'redmine'
require 'trustie' require 'trustie'
require 'redmine'
# Load the secret token from the Redmine configuration file # Load the secret token from the Redmine configuration file
secret = Redmine::Configuration['secret_token'] secret = Redmine::Configuration['secret_token']

@ -1523,6 +1523,9 @@ en:
label_excellent_courses_list: excellent_courses label_excellent_courses_list: excellent_courses
label_course_resource_list: course_resource_list label_course_resource_list: course_resource_list
label_project_resource_list: project_resource_list label_project_resource_list: project_resource_list
label_organization_list: organzation_list
label_latest_login_teacher_list: latest_login_teacher_list
label_latest_login_user_list: latest_login_teacher_list
#api #api
label_recently_updated_notification: Recently updated notification label_recently_updated_notification: Recently updated notification
@ -1535,3 +1538,12 @@ en:
error_upload_avatar_to_large: "too big (%{max_size})" error_upload_avatar_to_large: "too big (%{max_size})"
not_valid_image_file: not a valid image file not_valid_image_file: not a valid image file
#resource
label_resource_name: Resource_name
label_resource_type: Rescource_type
label_resource_size: Rescource_size
label_resource_upload_date: Resource_upload_date
label_resource_download_times: Resource_download_times
label_resource_upload_author: Resource_upload_author
label_resource_belongs_course: Resource_belongs_course
label_resource_belongs_project: Resource_belongs_project

@ -563,6 +563,7 @@ zh:
label_overall_activity: 活动概览 label_overall_activity: 活动概览
label_new: 新建 label_new: 新建
label_latest_login_user_list: 最近登录用户列表 label_latest_login_user_list: 最近登录用户列表
label_latest_login_teacher_list: 最近登录教师列表
label_logged_as: 登录为 label_logged_as: 登录为
label_environment: 环境 label_environment: 环境
@ -2112,3 +2113,13 @@ zh:
# 课程推荐 # 课程推荐
label_homework_commont: 作业 label_homework_commont: 作业
label_homework_recommendation: 课程推荐 label_homework_recommendation: 课程推荐
#资源
label_resource_name: 资源名称
label_resource_type: 资源类型
label_resource_size: 资源大小
label_resource_upload_date: 上传时间
label_resource_download_times: 下载次数
label_resource_upload_author: 上传者
label_resource_belongs_course: 所属课程
label_resource_belongs_project: 所属项目

@ -0,0 +1,11 @@
class CreateUserActions < ActiveRecord::Migration
def change
create_table :user_actions do |t|
t.integer :user_id
t.string :action_type
t.integer :action_id
t.timestamps
end
end
end

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160316055201) do ActiveRecord::Schema.define(:version => 20160317090350) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -1782,6 +1782,14 @@ ActiveRecord::Schema.define(:version => 20160316055201) do
t.integer "fields_bits", :default => 0 t.integer "fields_bits", :default => 0
end end
create_table "user_actions", :force => true do |t|
t.integer "user_id"
t.string "action_type"
t.integer "action_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "user_activities", :force => true do |t| create_table "user_activities", :force => true do |t|
t.string "act_type" t.string "act_type"
t.integer "act_id" t.integer "act_id"

@ -2,3 +2,4 @@ require 'trustie/utils'
require 'trustie/utils/image' require 'trustie/utils/image'
require 'trustie/gitlab/api' require 'trustie/gitlab/api'
require 'trustie/grack/grack' require 'trustie/grack/grack'
require 'trustie/at/at'

@ -0,0 +1,23 @@
#coding=utf-8
module Trustie
module At
extend ActiveSupport::Concern
module ClassMethods
def act_as_at_message(content, send_id)
self.send :define_method, :act_as_at_message_func do
users = self[content].scan /<span class="at" data-user-id="(.+?)">/m
users && users.flatten.uniq.each do |uids|
uids.split(",").each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self[send_id])
end
end
end
end
end
end
end
ActiveRecord::Base.send(:include, Trustie::At)

@ -247,11 +247,11 @@ function regexTopicDescription()
function submit_topic() function submit_topic()
{ {
if(regexTopicSubject() && regexTopicDescription()) // if(regexTopicSubject() && regexTopicDescription())
{ // {
message_content_editor.sync(); message_content_editor.sync();
$("#message-form").submit(); $("#message-form").submit();
} // }
} }
function reset_topic(){ function reset_topic(){

@ -54,7 +54,7 @@ function nh_check_field(params){
params.content.sync(); params.content.sync();
if(params.content.isEmpty()){ if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空'); params.contentmsg.html('请输入文章描述');
params.contentmsg.css({color:'#ff0000'}); params.contentmsg.css({color:'#ff0000'});
}else{ }else{
params.contentmsg.html('填写正确'); params.contentmsg.html('填写正确');
@ -131,7 +131,7 @@ function init_des_data(){
}); });
params.submit_btn.click(function () { params.submit_btn.click(function () {
params.editor.sync(); params.editor.sync();
params.form[0].submit(); params.form.submit();
}); });
params.textarea.data('init', 1); params.textarea.data('init', 1);
$(this).show(); $(this).show();

@ -32,19 +32,18 @@ $(function(){
return; return;
} }
$.post( $.ajax({
'/student_work/program_test', url: '/student_work/program_test',
{homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}, type: 'POST',
function(data,status){ timeout: 60*1000,
data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}
}).done(function(data){
tested = true; tested = true;
console.log(data); console.log(data);
if(data.index <=0){ if(data.index <=0){
data.index = $('.ProResultTop').length+1; data.index = $('.ProResultTop').length+1;
} }
if (typeof cb == 'function') {cb(data); return;} if (typeof cb == 'function') {cb(data); return;}
var html=bt('t:result-list',data); var html=bt('t:result-list',data);
$('.ProResult').prepend(html); $('.ProResult').prepend(html);
@ -54,8 +53,13 @@ $(function(){
$(".HomeWorkCon form").submit(); $(".HomeWorkCon form").submit();
} }
} }
}).fail(function(xhr, status){
if(status == 'timeout'){
alert("您的答案超时了, 请检查代码是否存在死循环的错误.");
} else {
alert("测试失败,服务器出错.")
} }
); });
}; };
$('#test-program-btn').on('click', test_program); $('#test-program-btn').on('click', test_program);

@ -3,11 +3,11 @@
*/ */
function submit_topic() function submit_topic()
{ {
if(regexTopicSubject() && regexTopicDescription()) // if(regexTopicSubject() && regexTopicDescription())
{ // {
message_content_editor.sync(); message_content_editor.sync();
$("#message-form").submit(); $("#message-form").submit();
} // }
} }
function regexTopicSubject() { function regexTopicSubject() {

@ -618,11 +618,11 @@ function regexTopicDescription()
} }
function submit_topic_project() function submit_topic_project()
{ {
if(regexTopicSubject() && regexTopicDescription()) // if(regexTopicSubject() && regexTopicDescription())
{ // {
message_content_editor.sync(); message_content_editor.sync();
$("#message-form-project").submit(); $("#message-form-project").submit();
} // }
} }
function reset_topic(){ function reset_topic(){

@ -1476,7 +1476,7 @@ a.choose-active {background-color:#269ac9; color:#ffffff;}
.subject-list-search {border:1px solid #dddddd; height:32px; width:250px;} .subject-list-search {border:1px solid #dddddd; height:32px; width:250px;}
.subject-list-info {width:385px; background-color:#f1f1f1; border:1px solid #dddddd; height:32px; line-height:32px; vertical-align:middle; text-align:center; color:#7a7a7a;} .subject-list-info {width:385px; background-color:#f1f1f1; border:1px solid #dddddd; height:32px; line-height:32px; vertical-align:middle; text-align:center; color:#7a7a7a;}
.subject-list-wrap {border:1px solid #dddddd; border-top:none; padding:10px; width:365px; height:460px; overflow-y:auto;} .subject-list-wrap {border:1px solid #dddddd; border-top:none; padding:10px; width:365px; height:460px; overflow-y:auto;}
.subject-content-wrapper {border:1px solid #dddddd; border-top:none; padding:10px; width:265px; height:430px; overflow-y:auto;} .subject-content-wrapper {border:1px solid #dddddd; border-top:none; padding:10px; width:265px; height:985px; overflow-y:auto;}
.subject-list-type {width:50px; text-align:center;} .subject-list-type {width:50px; text-align:center;}
.subject-list-count {width:60px; text-align:center;} .subject-list-count {width:60px; text-align:center;}
.subject-list-from {width:145px; text-align:center;} .subject-list-from {width:145px; text-align:center;}

@ -0,0 +1,8 @@
FactoryGirl.define do
factory :user_action, :class => 'UserActions' do
user_id 1
action_type "MyString"
action_id 1
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe UserActions, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save