Merge branch 'szzh' into sw_new_course
This commit is contained in:
commit
5f25cb9ebd
|
@ -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,返回该学校课程列表'
|
||||
|
@ -337,9 +340,56 @@ module Mobile
|
|||
get ':course_id/student_works_list' do
|
||||
cs = CoursesService.new
|
||||
student_works = cs.student_work_list params,current_user
|
||||
present :data,student_works.all,with:Mobile::Entities::StudentWork
|
||||
present :data,student_works,with:Mobile::Entities::StudentWork
|
||||
present :status,0
|
||||
end
|
||||
|
||||
desc '讨论区信息'
|
||||
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
|
||||
|
|
|
@ -4,56 +4,50 @@ module Mobile
|
|||
include Redmine::I18n
|
||||
def self.course_dynamic_expose(field)
|
||||
expose field do |c,opt|
|
||||
if field == :update_time
|
||||
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field)))
|
||||
elsif field == :news_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 1
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :document_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 3
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :topic_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 2
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :homework_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 4
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
else
|
||||
# if field == :news_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 1
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :document_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :topic_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 2
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :homework_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 4
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# else
|
||||
c[field] if (c.is_a?(Hash) && c.key?(field))
|
||||
end
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
course_dynamic_expose :type
|
||||
course_dynamic_expose :count
|
||||
course_dynamic_expose :course_name
|
||||
course_dynamic_expose :course_term
|
||||
course_dynamic_expose :course_time
|
||||
course_dynamic_expose :course_id
|
||||
course_dynamic_expose :course_img_url
|
||||
course_dynamic_expose :message
|
||||
course_dynamic_expose :update_time
|
||||
course_dynamic_expose :count
|
||||
course_dynamic_expose :news_count
|
||||
course_dynamic_expose :document_count
|
||||
course_dynamic_expose :topic_count
|
||||
|
@ -63,62 +57,32 @@ module Mobile
|
|||
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 :documents,using:Mobile::Entities::Attachment do |f,opt|
|
||||
# obj = nil
|
||||
# f[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:documents]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# end
|
||||
expose :topics,using:Mobile::Entities::Message do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 2
|
||||
obj = d[:topics]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:topics]
|
||||
end
|
||||
expose :homeworks,using:Mobile::Entities::Homework do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 4
|
||||
obj = d[:homeworks]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:homeworks]
|
||||
end
|
||||
|
||||
expose :news,using:Mobile::Entities::News do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 1
|
||||
obj = d[:news]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:news]
|
||||
end
|
||||
|
||||
expose :better_students,using:Mobile::Entities::User do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 6
|
||||
obj = d[:better_students]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:better_students]
|
||||
end
|
||||
|
||||
expose :active_students,using:Mobile::Entities::User do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 7
|
||||
obj = d[:active_students]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:active_students]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -337,6 +337,19 @@ class AdminController < ApplicationController
|
|||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#学校列表
|
||||
def schools
|
||||
@school_name = params[:school_name]
|
||||
if @school_name
|
||||
@schools = School.where("name like '%#{@school_name}%'")
|
||||
else
|
||||
@schools = School.all
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
#移动端版本管理
|
||||
def mobile_version
|
||||
@versions = PhoneAppVersion.reorder('created_at desc')
|
||||
|
@ -382,4 +395,74 @@ class AdminController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
#留言列表
|
||||
def leave_messages
|
||||
@jour = JournalsForMessage.where("jour_type = 'Principal' or jour_type = 'Course'").reorder('created_on desc')
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 30})
|
||||
else
|
||||
@limit = 30#per_page_option
|
||||
end
|
||||
|
||||
@jour_count = @jour.count
|
||||
@jour_pages = Paginator.new @jour_count, @limit, params['page']
|
||||
@offset ||= @jour_pages.offset
|
||||
@jour = @jour.limit(@limit).offset(@offset).all
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#帖子
|
||||
def messages_list
|
||||
@memo = Memo.reorder("created_at desc")
|
||||
|
||||
=begin
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 30})
|
||||
else
|
||||
@limit = 30#per_page_option
|
||||
end
|
||||
|
||||
@memo_count = @memo.count
|
||||
@memo_pages = Paginator.new @memo_count, @limit, params['page']
|
||||
@offset ||= @memo_pages.offset
|
||||
@memo = @memo.limit(@limit).offset(@offset).all
|
||||
=end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#课程讨论区的帖子
|
||||
def course_messages
|
||||
#@boards=Board.where('course_id is NULL')
|
||||
#@course_ms = Message.reorder('created_on desc')
|
||||
@course_ms=Message.joins("join boards on messages.board_id=boards.id where boards.course_id is not NULL").reorder('created_on desc')
|
||||
end
|
||||
|
||||
#项目讨论区的帖子
|
||||
def project_messages
|
||||
@project_ms=Message.joins("join boards on messages.board_id=boards.id where boards.project_id != -1").reorder('created_on desc')
|
||||
end
|
||||
|
||||
#通知
|
||||
def notices
|
||||
@news = News.where('course_id is not NULL').order('created_on desc')
|
||||
end
|
||||
|
||||
#最近登录用户列表
|
||||
def latest_login_users
|
||||
@user = User.order('last_login_on desc')
|
||||
end
|
||||
|
||||
#作业
|
||||
def homework
|
||||
@homework = HomeworkCommon.order('end_time desc')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -514,6 +514,8 @@ private
|
|||
end
|
||||
|
||||
def has_login
|
||||
render_403 unless User.current.logged?
|
||||
unless @attachment && @attachment.container_type == "PhoneAppVersion"
|
||||
render_403 unless User.current.logged?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,11 +20,10 @@ class CoursesController < ApplicationController
|
|||
menu_item l(:label_sort_by_influence), :only => :index
|
||||
|
||||
before_filter :can_show_course, :except => []
|
||||
before_filter :logged_user_by_apptoken,:only => [:show,:new_homework,:feedback]
|
||||
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
|
||||
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
||||
before_filter :logged_user_by_apptoken,:only => [:show,:feedback]
|
||||
before_filter :find_course, :except => [ :index, :search, :new,:join,:unjoin, :create, :new_join, :course,:join_private_courses]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :update, :course]
|
||||
before_filter :authorize_course_global, :only => [:new,:create]
|
||||
before_filter :toggleCourse, :only => [:finishcourse, :restartcourse]
|
||||
|
||||
before_filter :require_login, :only => [:join, :unjoin]
|
||||
|
@ -40,9 +39,14 @@ class CoursesController < ApplicationController
|
|||
else
|
||||
@state = 5 #未登录
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
|
||||
end
|
||||
# if @state == 1 || @state == 3
|
||||
# respond_to course_path(course.id)
|
||||
# else
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
|
||||
end
|
||||
#end
|
||||
|
||||
rescue Exception => e
|
||||
@state = 4 #已经加入了课程
|
||||
respond_to do |format|
|
||||
|
@ -102,74 +106,17 @@ class CoursesController < ApplicationController
|
|||
# 课程搜索
|
||||
# add by nwb
|
||||
def search
|
||||
courses_all = Course.all_course
|
||||
name = params[:name]
|
||||
if name.blank?
|
||||
@courses = []
|
||||
@courses_all = []
|
||||
@course_count = 0
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
if params[:name].empty?
|
||||
courses = Course.visible
|
||||
@courses = paginateHelper courses,10
|
||||
else
|
||||
@courses = courses_all.visible
|
||||
if params[:name].present?
|
||||
@courses_all = @courses.like(params[:name])
|
||||
else
|
||||
@courses_all = @courses;
|
||||
end
|
||||
@course_count = @courses_all.count
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
|
||||
# 课程的动态数
|
||||
@course_activity_count=Hash.new
|
||||
@courses_all.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
end
|
||||
|
||||
case params[:course_sort_type]
|
||||
when '0'
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@s_type = 0
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '1'
|
||||
@courses = @courses_all.order("course_ac_para desc")
|
||||
@s_type = 1
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '2'
|
||||
@courses = @courses_all.order("watchers_count desc")
|
||||
@s_type = 2
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
when '3'
|
||||
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
||||
@courses=handle_course @courses_all,@course_activity_count
|
||||
@s_type = 3
|
||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||
|
||||
else
|
||||
@s_type = 0
|
||||
@courses = @courses_all.order("created_at desc")
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
|
||||
end
|
||||
courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'")
|
||||
@courses = paginateHelper courses,10
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'course_base'
|
||||
scope = Course
|
||||
unless params[:closed]
|
||||
scope = scope.active
|
||||
end
|
||||
}
|
||||
format.atom {
|
||||
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||
|
@ -605,7 +552,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
def toggleCourse
|
||||
@course_prefs = Course.find_by_extra(@course.extra)
|
||||
unless (@course_prefs.teacher == User.current || User.current.admin?)
|
||||
unless (User.current.allowed_to?(:as_teacher,@course_prefs) || User.current.admin?)
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
@ -659,92 +606,9 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
|
||||
return
|
||||
end
|
||||
@users_by_role = @course.users_by_role
|
||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||
end
|
||||
@key = User.current.rss_key
|
||||
#新增内容
|
||||
@days = Setting.activity_days_default.to_i
|
||||
if params[:from]
|
||||
begin; @date_to = params[:from].to_date + 1; rescue; end
|
||||
end
|
||||
has = {
|
||||
"show_course_files" => true,
|
||||
"show_course_news" => true,
|
||||
"show_course_messages" => true,
|
||||
#"show_course_journals_for_messages" => true,
|
||||
# "show_bids" => true,
|
||||
# "show_homeworks" => true,
|
||||
"show_polls" => true
|
||||
}
|
||||
@date_to ||= Date.today + 1
|
||||
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
||||
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
||||
if @author.nil?
|
||||
# 显示老师和助教的活动
|
||||
# @authors = searchTeacherAndAssistant(@course)
|
||||
@authors = course_all_member(@course)
|
||||
events = []
|
||||
key = "course_events_#{@course.id}".to_sym
|
||||
if Rails.env.production? && Setting.course_cahce_enabled?
|
||||
events = Rails.cache.read(key) || []
|
||||
end
|
||||
if events.empty?
|
||||
@authors.each do |author|
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||
:with_subprojects => false,
|
||||
:author => author.user)
|
||||
|
||||
@activity.scope_select {|t| has["show_#{t}"]}
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events += @activity.events(@days, @course.created_at)
|
||||
else
|
||||
events += @activity.events(@days, @course.created_at, :is_public => 1)
|
||||
end
|
||||
end
|
||||
Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
|
||||
end
|
||||
else
|
||||
# @author = @course.teacher
|
||||
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||
:with_subprojects => false,
|
||||
:author => @author)
|
||||
|
||||
@activity.scope_select {|t| has["show_#{t}"]}
|
||||
# modify by nwb
|
||||
# 添加私密性判断
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events(@days, @course.created_at)
|
||||
else
|
||||
events = @activity.events(@days, @course.created_at, :is_public => 1)
|
||||
end
|
||||
end
|
||||
|
||||
# 无新动态时,显示老动态
|
||||
if events.count == 0
|
||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||
events = @activity.events
|
||||
else
|
||||
events = @activity.events(:is_public => 1)
|
||||
end
|
||||
end
|
||||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||
end
|
||||
|
||||
sorted_events = sort_activity_events_course(events)
|
||||
events = paginateHelper sorted_events,10
|
||||
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||
# documents
|
||||
|
||||
|
||||
course_activities = @course.course_activities.order("created_at desc")
|
||||
@canShowRealName = User.current.member_of_course? @course
|
||||
@course_activities = paginateHelper course_activities,10
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses'}
|
||||
format.api
|
||||
|
@ -809,6 +673,12 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#删除课程
|
||||
#删除课程只是将课程的is_delete状态改为false,is_delete为false状态的课程只有管理员可以看到
|
||||
def destroy
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def allow_join course
|
||||
if course_endTime_timeout? course
|
||||
|
|
|
@ -177,11 +177,11 @@ class FilesController < ApplicationController
|
|||
def index
|
||||
@flag = params[:flag] || false
|
||||
#sort_init 'filename', 'asc'
|
||||
sort_init 'created_on', 'desc'
|
||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
'filename' => "#{Attachment.table_name}.filename",
|
||||
'size' => "#{Attachment.table_name}.filesize",
|
||||
'downloads' => "#{Attachment.table_name}.downloads"
|
||||
# sort_init 'created_on', 'desc'
|
||||
# sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
# 'filename' => "#{Attachment.table_name}.filename",
|
||||
# 'size' => "#{Attachment.table_name}.filesize",
|
||||
# 'downloads' => "#{Attachment.table_name}.downloads"
|
||||
sort = ""
|
||||
@sort = ""
|
||||
@order = ""
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class HomeworkCommonController < ApplicationController
|
||||
require 'net/http'
|
||||
require 'json'
|
||||
require "base64"
|
||||
layout "base_courses"
|
||||
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]
|
||||
|
@ -18,6 +19,28 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@homework_type = "1"
|
||||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 2
|
||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
|
||||
if @homework_type == "1"
|
||||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 2
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.homework_detail_manual = @homework_detail_manual
|
||||
elsif @homework_type == "2"
|
||||
#编程作业相关属性
|
||||
@homework_detail_programing = HomeworkDetailPrograming.new
|
||||
@homework.homework_detail_programing = @homework_detail_programing
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
|
@ -29,7 +52,7 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 0
|
||||
@homework.late_penalty = 2
|
||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
|
||||
|
@ -37,7 +60,7 @@ class HomeworkCommonController < ApplicationController
|
|||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 0
|
||||
@homework_detail_manual.absence_penalty = 2
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
|
@ -71,18 +94,20 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
if homework.homework_type == 2
|
||||
homework_detail_programing = HomeworkDetailPrograming.new
|
||||
homework_detail_programing.language = "C++"
|
||||
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]
|
||||
if params[:input] && params[:output] && params[:result]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
homework.homework_tests << homework_test
|
||||
question[:input] << homework_test.input
|
||||
question[:output] << homework_test.output
|
||||
|
@ -122,6 +147,8 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
|
||||
if homework.save
|
||||
homework_detail_programing.save if homework_detail_programing
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
@ -151,7 +178,7 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework.description = params[:homework_common][:description]
|
||||
@homework.end_time = params[:homework_common][:end_time]
|
||||
@homework.publish_time = params[:homework_common][:publish_time]
|
||||
@homework.homework_type = params[:homework_common][:homework_type]
|
||||
@homework.homework_type = params[:homework_common][:homework_type] if params[:homework_common][:homework_type]
|
||||
unless @homework.late_penalty == params[:late_penalty]
|
||||
@homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work|
|
||||
student_work.late_penalty = params[:late_penalty]
|
||||
|
@ -187,8 +214,9 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
|
||||
if @homework.homework_type == 2 && @homework_detail_programing #编程作业
|
||||
@homework_detail_programing.language = "C++"
|
||||
@homework_detail_programing.language = params[:language]
|
||||
@homework_detail_programing.standard_code = params[:standard_code]
|
||||
@homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_tests = @homework.homework_tests
|
||||
#需要删除的测试
|
||||
ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i)
|
||||
|
@ -196,23 +224,45 @@ class HomeworkCommonController < ApplicationController
|
|||
homework_test = HomeworkTest.find id
|
||||
homework_test.destroy if homework_test
|
||||
end
|
||||
if params[:input] && params[:output]
|
||||
if params[:input] && params[:output] && params[:result]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
homework_test = HomeworkTest.find_by_id k
|
||||
if homework_test #已存在的测试,修改
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
else #不存在的测试,增加
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework_test.error_msg = params[:error_msg]
|
||||
homework_test.homework_common = @homework
|
||||
end
|
||||
homework_test.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#发送修改作业的请求
|
||||
question = {title:@homework.name,content:@homework.description}
|
||||
question[:input] = []
|
||||
question[:output] = []
|
||||
@homework.homework_tests.each do |test|
|
||||
question[:input] << test.input
|
||||
question[:output] << test.output
|
||||
end
|
||||
uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json")
|
||||
body = question.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Put.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
end
|
||||
|
||||
@homework.save_attachments(params[:attachments])
|
||||
|
@ -308,6 +358,24 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def programing_test
|
||||
test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
|
||||
@index = params[:index]
|
||||
uri = URI('http://192.168.80.21:8080/api/realtime.json')
|
||||
body = test.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
@err_msg = result["compile_error_msg"]
|
||||
result["results"].each do |re|
|
||||
@result = re["status"]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取课程
|
||||
def find_course
|
||||
|
|
|
@ -112,7 +112,19 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
|
||||
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
|
||||
query = @issue.forge_messages
|
||||
if User.current.id == @issue.assigned_to_id
|
||||
query.update_all(:viewed => true)
|
||||
end
|
||||
# 缺陷状态更新
|
||||
query_journals = @issue.journals
|
||||
if User.current.id == @issue.author_id
|
||||
query_journals.each do |query_journal|
|
||||
query_journal.forge_messages.update_all(:viewed => true)
|
||||
end
|
||||
end
|
||||
#
|
||||
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
|
||||
@journals.each_with_index {|j,i| j.indice = i+1}
|
||||
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
||||
|
|
|
@ -25,6 +25,7 @@ class MyController < ApplicationController
|
|||
helper :issues
|
||||
helper :users
|
||||
helper :custom_fields
|
||||
helper :user_score
|
||||
|
||||
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
||||
'issuesreportedbyme' => :label_reported_issues,
|
||||
|
@ -88,6 +89,23 @@ class MyController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def clear_user_avatar_temp
|
||||
@user = User.current
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
diskfile1 = diskfile + 'temp'
|
||||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
def save_user_avatar
|
||||
@user = User.current
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
diskfile1 = diskfile + 'temp'
|
||||
begin
|
||||
FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
|
||||
ensure
|
||||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
end
|
||||
|
||||
# Edit user's account
|
||||
def account
|
||||
@user = User.current
|
||||
|
@ -119,6 +137,8 @@ class MyController < ApplicationController
|
|||
@se.identity = params[:identity].to_i if params[:identity]
|
||||
@se.technical_title = params[:technical_title] if params[:technical_title]
|
||||
@se.student_id = params[:no] if params[:no]
|
||||
@se.brief_introduction = params[:brief_introduction]
|
||||
@se.description = params[:description]
|
||||
|
||||
if @user.save && @se.save
|
||||
# 头像保存
|
||||
|
@ -137,6 +157,7 @@ class MyController < ApplicationController
|
|||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
# Destroys user's account
|
||||
|
@ -159,6 +180,8 @@ class MyController < ApplicationController
|
|||
|
||||
# Manage user's password
|
||||
def password
|
||||
begin
|
||||
@act='password'
|
||||
@user = User.current
|
||||
unless @user.change_password_allowed?
|
||||
flash.now[:error] = l(:notice_can_t_change_password)
|
||||
|
@ -174,16 +197,20 @@ class MyController < ApplicationController
|
|||
Token.delete_user_all_tokens(@user)
|
||||
logout_user
|
||||
redirect_to signin_url(back_url: my_account_path)
|
||||
return
|
||||
else
|
||||
flash.now[:error] = l(:notice_account_wrong_password)
|
||||
#flash.now[:error] = l(:notice_account_wrong_password)
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == 'wrong password'
|
||||
flash.now[:error] = l(:notice_account_wrong_password)
|
||||
# flash.now[:error] = l(:notice_account_wrong_password)
|
||||
else
|
||||
flash.now[:error] = e.message
|
||||
# flash.now[:error] = e.message
|
||||
end
|
||||
flash.now[:error] = l(:notice_account_old_wrong_password)
|
||||
end
|
||||
render :template => 'my/account',:layout=>'base_users_new'
|
||||
end
|
||||
|
||||
# Create a new feeds key
|
||||
|
|
|
@ -71,10 +71,15 @@ class NewsController < ApplicationController
|
|||
scope = @course ? @course.news.course_visible : News.course_visible
|
||||
|
||||
@news_count = scope.count
|
||||
#@news_pages = Paginator.new @news_count, @limit, params['page']
|
||||
#@offset ||= scope_page.offset
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
@q = params[:subject]
|
||||
if params[:subject].nil? || params[:subject].blank?
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
else
|
||||
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
end
|
||||
|
||||
# :offset => @offset,
|
||||
# :limit => @limit)
|
||||
@newss = paginateHelper scope_order,10
|
||||
|
@ -83,6 +88,7 @@ class NewsController < ApplicationController
|
|||
@news = News.new
|
||||
render :layout => 'base_courses'
|
||||
}
|
||||
format.js
|
||||
format.api
|
||||
format.atom { render_feed(@newss, :title => (@course ? @course.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
||||
end
|
||||
|
@ -141,7 +147,7 @@ class NewsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
|
||||
teachers = searchTeacherAndAssistant(@course)
|
||||
for teacher in teachers
|
||||
if(teacher.user_id != User.current.id)
|
||||
|
@ -155,7 +161,7 @@ class NewsController < ApplicationController
|
|||
notify.save()
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
|
||||
render_attachment_warning_if_needed(@news)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to course_news_index_url(@course)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#encoding utf-8
|
||||
class PollController < ApplicationController
|
||||
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll]
|
||||
before_filter :find_container, :only => [:new,:create, :index]
|
||||
|
@ -137,11 +138,19 @@ class PollController < ApplicationController
|
|||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
end
|
||||
if @poll_questions.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
# 如果是插入的话,那么从插入的这个id以后的question_num都将要+1
|
||||
if params[:quest_id]
|
||||
@is_insert = true
|
||||
@poll.poll_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1")
|
||||
@poll_question_num = params[:quest_num].to_i
|
||||
@poll_questions.question_number = params[:quest_num].to_i + 1
|
||||
end
|
||||
if @poll_questions.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#修改题目
|
||||
|
@ -328,6 +337,37 @@ class PollController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def import_poll
|
||||
@poll = Poll.find(params[:to_id])
|
||||
question_num = @poll.poll_questions.select("max(question_number) question_number").first.question_number
|
||||
import_poll = Poll.find(params[:import_id])
|
||||
import_poll.poll_questions.each_with_index do |question,index|
|
||||
option = {
|
||||
:is_necessary => question.is_necessary,
|
||||
:question_title => question.question_title,
|
||||
:question_type => question.question_type,
|
||||
:question_number => question_num + index+1
|
||||
}
|
||||
poll_questions = @poll.poll_questions.new option
|
||||
for i in 1..question.poll_answers.count
|
||||
answer = question.poll_answers[i-1][:answer_text]
|
||||
question_option = {
|
||||
:answer_position => i,
|
||||
:answer_text => answer
|
||||
}
|
||||
poll_questions.poll_answers.new question_option
|
||||
end
|
||||
@poll.poll_questions << poll_questions
|
||||
end
|
||||
if @poll.save
|
||||
@poll = Poll.find(params[:to_id])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#重新发布问卷
|
||||
def republish_poll
|
||||
@poll.poll_questions.each do |poll_question|
|
||||
|
@ -371,6 +411,70 @@ class PollController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 将其他地方的问卷导出来
|
||||
def other_poll
|
||||
# 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入
|
||||
tea_ids = '('
|
||||
tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
|
||||
@polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
|
||||
@polls_group_id = params[:polls_group_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 将问卷导入本课程
|
||||
def import_other_poll
|
||||
course_id = params[:course_id]
|
||||
@course = Course.find(course_id)
|
||||
params[:polls].each_with_index do |p,i|
|
||||
poll = Poll.find(p)
|
||||
option = {
|
||||
:polls_name => poll.polls_name || l(:label_poll_new),
|
||||
:polls_type => 'Course',
|
||||
:polls_group_id => course_id,
|
||||
:polls_status => 1,
|
||||
:user_id => User.current.id,
|
||||
:published_at => Time.now,
|
||||
:closed_at => Time.now,
|
||||
:show_result => 1,
|
||||
:polls_description => poll.polls_description
|
||||
}
|
||||
@poll = Poll.create option
|
||||
|
||||
poll.poll_questions.each do | q|
|
||||
#question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
||||
option = {
|
||||
:is_necessary => q[:is_necessary],
|
||||
:question_title => q[:question_title],
|
||||
:question_type => q[:question_type] || 1,
|
||||
:question_number => q[:question_number]
|
||||
}
|
||||
@poll_questions = @poll.poll_questions.new option
|
||||
|
||||
for i in 1..q.poll_answers.count
|
||||
answer = q.poll_answers[i-1].nil? ? l(:label_new_answer) : q.poll_answers[i-1][:answer_text]
|
||||
question_option = {
|
||||
:answer_position => i,
|
||||
:answer_text => answer
|
||||
}
|
||||
@poll_questions.poll_answers.new question_option
|
||||
end
|
||||
end
|
||||
@poll.save
|
||||
end
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
if @is_teacher
|
||||
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
|
||||
else
|
||||
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
|
||||
end
|
||||
@polls = paginateHelper polls,20 #分页
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_poll_and_course
|
||||
@poll = Poll.find params[:id]
|
||||
|
|
|
@ -86,8 +86,14 @@ class ProjectsController < ApplicationController
|
|||
@project_pages = Project.project_entities.visible.like(params[:name]).page(params[:page]).per(10)
|
||||
else
|
||||
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
|
||||
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
|
||||
end
|
||||
@projects = @project_pages.order("created_on desc")
|
||||
@limit = 10#per_page_option
|
||||
|
||||
@project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
|
||||
@project_pages = Paginator.new @project_count, @limit, params['page']
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
|
@ -150,11 +156,15 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
render :layout => 'base'
|
||||
if User.current.login?
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
render :layout => 'base'
|
||||
else
|
||||
redirect_to signin_url
|
||||
end
|
||||
end
|
||||
|
||||
def share
|
||||
|
@ -167,6 +177,10 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
unless User.current.login?
|
||||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
|
@ -280,11 +294,11 @@ class ProjectsController < ApplicationController
|
|||
|
||||
# 根据私密性,取出符合条件的所有数据
|
||||
if User.current.member_of?(@project) || User.current.admin?
|
||||
@events_pages = ForgeActivity.where("project_id = ?",@project).order("created_at desc").page(params['page'|| 1]).per(20);
|
||||
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type != ?",@project, "Document" ).order("created_at desc").page(params['page'|| 1]).per(20);
|
||||
#events = @activity.events(@date_from, @date_to)
|
||||
else
|
||||
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
|
||||
= ?",@project,1).order("created_at desc")
|
||||
= ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc")
|
||||
.page(params['page'|| 1]).per(10);
|
||||
# @events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||
end
|
||||
|
|
|
@ -250,6 +250,14 @@ update
|
|||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
if params[:to] == 'gitlab'
|
||||
g = Gitlab.client
|
||||
g.post('/session', body: {email: User.current.mail, password: User.current.hashed_password})
|
||||
redirect_to "http://192.168.41.130:3000/gitlab-org/gitlab-shell/tree/master"
|
||||
return
|
||||
end
|
||||
|
||||
#if( !User.current.member_of?(@project) || @project.hidden_repo)
|
||||
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||
|
||||
|
@ -441,6 +449,8 @@ update
|
|||
def stats
|
||||
@project_id = params[:id]
|
||||
@repository_id = @repository.identifier
|
||||
# 提交次数统计
|
||||
@status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id])
|
||||
render :layout => 'base_projects'
|
||||
end
|
||||
|
||||
|
@ -451,6 +461,12 @@ update
|
|||
data = graph_commits_per_month(@repository)
|
||||
when "commits_per_author"
|
||||
data = graph_commits_per_author(@repository)
|
||||
when "author_commits_per_month"
|
||||
data = graph_author_commits_per_month(@repository)
|
||||
when "author_commits_six_month"
|
||||
data = author_commits_six_month(@repository)
|
||||
when "author_code_six_months"
|
||||
data = author_code_six_month(@repository)
|
||||
end
|
||||
if data
|
||||
headers["Content-Type"] = "image/svg+xml"
|
||||
|
@ -476,7 +492,18 @@ update
|
|||
if params[:repository_id].present?
|
||||
@repository = @project.repositories.find_by_identifier_param(params[:repository_id])
|
||||
else
|
||||
@repository = @project.repository
|
||||
# 多版本库,如果一个版本库为空则去下一个
|
||||
rep_count = @project.repositories.count
|
||||
if @project.repository.nil?
|
||||
for i in 0..rep_count
|
||||
unless @project.repositories[i].nil?
|
||||
@repository = @project.repositories[i]
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
@repository = @project.repository
|
||||
end
|
||||
end
|
||||
(render_404; return false) unless @repository
|
||||
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
|
||||
|
@ -540,11 +567,12 @@ update
|
|||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:step_x_labels => 2,
|
||||
:show_data_values => false,
|
||||
:show_data_values => true,
|
||||
:graph_title => l(:label_commits_per_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
|
||||
# 具状图
|
||||
graph.add_data(
|
||||
:data => commits_by_month[0..11].reverse,
|
||||
:title => l(:label_revision_plural)
|
||||
|
@ -560,7 +588,7 @@ update
|
|||
|
||||
def graph_commits_per_author(repository)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
|
||||
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
|
||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||
|
@ -582,7 +610,7 @@ update
|
|||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => false,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_commits_per_author),
|
||||
:show_graph_title => true
|
||||
|
@ -597,6 +625,123 @@ update
|
|||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户最近一年的提交次数
|
||||
def graph_author_commits_per_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 12
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer,
|
||||
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_commits_year),
|
||||
:show_graph_title => true,
|
||||
:no_css => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_commit_count)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户最近六个月的提交次数
|
||||
def author_commits_six_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 6
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer,
|
||||
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_commits_six_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_commit_count)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 最近六个月代码量统计
|
||||
def author_code_six_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 6
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
|
||||
commits_by_author = Changeset.count(:group => :committer, :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40)
|
||||
all_author = []
|
||||
commits_by_author.each do |cba|
|
||||
all_author << cba.first
|
||||
end
|
||||
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
|
||||
all_author = all_author.collect {|c| c.split.first }
|
||||
commits_by_author = repository.commits(all_author, "#{@date_from}", "#{@date_to}", repository.id == 150 ? "szzh" : 'master')
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_code_six_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:lable_revision_code_count)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
|
||||
def check_hidden_repo
|
||||
project = Project.find(params[:id])
|
||||
if !User.current.member_of?(project)
|
||||
|
|
|
@ -4,28 +4,21 @@ class SchoolController < ApplicationController
|
|||
|
||||
def upload
|
||||
uploaded_io = params[:logo]
|
||||
school_id = 0
|
||||
schools = School.where("name = ?", params[:school])
|
||||
|
||||
schools.each do |s|
|
||||
school_id = s.id
|
||||
end
|
||||
|
||||
school_id ||= params[:id]
|
||||
unless uploaded_io.nil?
|
||||
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
|
||||
file.write(uploaded_io.read)
|
||||
end
|
||||
|
||||
s1 = School.find(school_id)
|
||||
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
|
||||
s1.save
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
redirect_to admin_schools_url(:school_name => params[:school_name])
|
||||
end
|
||||
|
||||
def upload_logo
|
||||
|
||||
@school = School.find params[:id]
|
||||
@school_name = params[:school_name]
|
||||
end
|
||||
|
||||
#获取制定学校开设的课程数
|
||||
|
|
|
@ -13,8 +13,9 @@ class StudentWorkController < ApplicationController
|
|||
def index
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
unless @group == "0" || @group.nil?
|
||||
group_students = CourseGroup.find_by_id(@group).users
|
||||
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
|
||||
|
@ -127,7 +128,7 @@ class StudentWorkController < ApplicationController
|
|||
solutions = {
|
||||
student_work_id:stundet_work.id,
|
||||
src:Base64.encode64(stundet_work.description),
|
||||
language:1
|
||||
language:@homework.homework_detail_programing.language
|
||||
}
|
||||
uri = URI(url)
|
||||
body = solutions.to_json
|
||||
|
@ -156,7 +157,7 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
if @homework.homework_type == 2 #编程作业不能修改作业
|
||||
if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业
|
||||
render_403
|
||||
else
|
||||
respond_to do |format|
|
||||
|
@ -386,8 +387,8 @@ class StudentWorkController < ApplicationController
|
|||
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
|
||||
homework_tests = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'")
|
||||
homework_tests.each do |homework_test|
|
||||
student_work_test = StudentWorkTest.new
|
||||
student_work_test.student_work = stundet_work
|
||||
student_work_test.homework_test = homework_test
|
||||
|
@ -395,6 +396,7 @@ class StudentWorkController < ApplicationController
|
|||
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
|
||||
|
@ -443,7 +445,7 @@ class StudentWorkController < ApplicationController
|
|||
#判断是不是当前作品的提交者
|
||||
#提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
|
||||
def author_of_work
|
||||
render_403 unless (User.current.id == @work.user_id || User.current.admin?) && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||
render_403 unless User.current.admin? || (User.current.id == @work.user_id && @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
|
||||
end
|
||||
|
||||
def teacher_of_course
|
||||
|
@ -466,22 +468,60 @@ class StudentWorkController < ApplicationController
|
|||
sheet1 = book.create_worksheet :name => "homework"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.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
|
||||
if @homework.homework_type == 0 #普通作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
# sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,8] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,9] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
elsif @homework.homework_type == 1 #匿评作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
elsif @homework.homework_type == 2 #编程作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
sheet1[count_row,0]=homework.user.id
|
||||
sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
|
||||
sheet1[count_row,2] = homework.user.login
|
||||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
|
|
|
@ -26,10 +26,11 @@ class UsersController < ApplicationController
|
|||
menu_item :user_homework, :only => :user_homeworks
|
||||
menu_item :user_project, :only => [:user_projects, :watch_projects]
|
||||
# menu_item :requirement_focus, :only => :watch_bids
|
||||
menu_item :requirement_focus, :only => :watch_contests
|
||||
menu_item :requirement_focus, :only => :watch_contests
|
||||
menu_item :user_newfeedback, :only => :user_newfeedback
|
||||
|
||||
|
||||
menu_item :user_messages, :only => :user_messages
|
||||
|
||||
|
||||
#Ended by young
|
||||
|
||||
# edit
|
||||
|
@ -39,23 +40,28 @@ class UsersController < ApplicationController
|
|||
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
|
||||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index]
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index]
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
#before_filter :rest_user_score, only: :show
|
||||
#before_filter :select_entry, only: :user_projects
|
||||
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
|
||||
|
||||
|
||||
#william
|
||||
before_filter :require_login, :only => [:tag_save,:tag_saveEx]
|
||||
#before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback]
|
||||
|
||||
|
||||
#visitor
|
||||
before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist]
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :custom_fields
|
||||
|
@ -76,6 +82,9 @@ class UsersController < ApplicationController
|
|||
|
||||
# fq
|
||||
helper :words
|
||||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
|
||||
def refresh_changests
|
||||
if !(@user.nil?) && !(@user.memberships.nil?)
|
||||
|
@ -87,6 +96,41 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 用户消息
|
||||
def user_messages
|
||||
unless User.current.logged?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
# 当前用户查看消息,则设置消息为已读
|
||||
querys = @user.course_messages
|
||||
if User.current.id == @user.id
|
||||
querys.update_all(:viewed => true)
|
||||
end
|
||||
if @user.course_messages
|
||||
if params[:type].nil?
|
||||
@user_course_messages = @user.course_messages.reverse
|
||||
@user_project_messges = @user.forge_messages.reverse
|
||||
else
|
||||
case params[:type]
|
||||
when 'homework'
|
||||
@user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "HomeworkCommon"}
|
||||
#@user_course_messages = ForgeMessage.find_by_sql("select * from course_messages where user_id='#{@user.id}' and course_message_type = 'HomeworkCommon' order by created_at desc;")
|
||||
when 'message'
|
||||
@user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "Message"}
|
||||
when 'news'
|
||||
@user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "News"}
|
||||
when 'poll'
|
||||
@user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "Poll"}
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{render :layout=>'base_users_new'}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def user_projects_index
|
||||
if User.current.admin?
|
||||
memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first
|
||||
|
@ -104,34 +148,22 @@ class UsersController < ApplicationController
|
|||
|
||||
#added by young
|
||||
def user_projects
|
||||
if User.current.admin?
|
||||
@memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
|
||||
else
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
@memberships = @user.memberships.all(:conditions => cond)
|
||||
end
|
||||
@memberships = @memberships.sort {|a,b| b.created_on.to_i <=> a.created_on.to_i}
|
||||
# unless @memberships.nil?
|
||||
# @user_projects = []
|
||||
# @memberships.each do |membership|
|
||||
# @user_projects << membership.project
|
||||
# end
|
||||
# @user_projects = @user_projects.sort {|a,b| b.created_on.to_i <=> a.created_on.to_i}
|
||||
# end
|
||||
#events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
|
||||
#@events_by_day = events.group_by(&:event_date)
|
||||
@state = 0
|
||||
#add by huang
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
render_404
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc")
|
||||
if(params[:status] == '1')
|
||||
projects = projects.where("projects.user_id = ?",@user.id)
|
||||
elsif(params[:status] == '2')
|
||||
projects = projects.where("projects.user_id <> ?",@user.id)
|
||||
end
|
||||
@list = paginateHelper projects,10
|
||||
@params = params[:status]
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.html{render :layout=>'base_users_new'}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
@ -168,21 +200,21 @@ class UsersController < ApplicationController
|
|||
# format.api
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
#new add by linchun
|
||||
def watch_contests
|
||||
@bids = Contest.watched_by(@user)
|
||||
def watch_contests
|
||||
@bids = Contest.watched_by(@user)
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@contest_count = @contests.count
|
||||
@contest_pages = Paginator.new @contest_count, @limit, params['page']
|
||||
@offset ||= @contest_pages.reverse_offset
|
||||
@offset ||= @contest_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@contest = @contests.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @bid_count % @limit
|
||||
@contest = @contests.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_users'
|
||||
|
@ -219,9 +251,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
# end
|
||||
|
||||
|
||||
# added by huang
|
||||
def user_homeworks
|
||||
def user_homeworks
|
||||
# @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
# @memberships = []
|
||||
# @membership.each do |membership|
|
||||
|
@ -240,65 +272,42 @@ class UsersController < ApplicationController
|
|||
# return
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
include CoursesHelper
|
||||
def user_courses
|
||||
def user_courses
|
||||
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
if !@user.active?
|
||||
render_404
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
|
||||
if User.current == @user || User.current.admin?
|
||||
membership = @user.coursememberships.all
|
||||
else
|
||||
membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
|
||||
if(params[:status] == '1')
|
||||
courses = courses.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now)
|
||||
elsif(params[:status] == '2')
|
||||
courses = courses.where("endup_time < ?",Time.now)
|
||||
end
|
||||
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
@memberships = []
|
||||
membership.collect { |e| @memberships.push(e)}
|
||||
## 判断课程是否过期 [需封装]
|
||||
@memberships_doing = []
|
||||
@memberships_done = []
|
||||
#now_time = Time.now.year
|
||||
@memberships.map { |e|
|
||||
#end_time = e.course.get_time.year
|
||||
isDone = course_endTime_timeout?(e.course)
|
||||
if isDone
|
||||
@memberships_done.push e
|
||||
else
|
||||
@memberships_doing.push e
|
||||
end
|
||||
}
|
||||
# respond_to do |format|
|
||||
# format.html
|
||||
# format.api
|
||||
# end
|
||||
@list = paginateHelper courses,10
|
||||
@params = params[:status]
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
# modified by fq
|
||||
def user_newfeedback
|
||||
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jours.update_all(:is_readed => true, :status => false)
|
||||
@jours.each do |journal|
|
||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||
jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
if User.current == @user
|
||||
jours.update_all(:is_readed => true, :status => false)
|
||||
jours.each do |journal|
|
||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||
end
|
||||
end
|
||||
|
||||
#@limit = 10
|
||||
#@feedback_count = @jours.count
|
||||
#@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
#@offset ||= @feedback_pages.offset
|
||||
@jour = paginateHelper @jours,10
|
||||
@jour = paginateHelper jours,10
|
||||
@state = false
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
# end
|
||||
|
||||
def user_comments
|
||||
|
||||
|
@ -306,7 +315,7 @@ class UsersController < ApplicationController
|
|||
|
||||
#end
|
||||
def index
|
||||
|
||||
|
||||
@status = params[:status] || 1
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
@ -322,7 +331,7 @@ class UsersController < ApplicationController
|
|||
# 先内连一下statuses 保证排序之后数量一致
|
||||
scope = User.visible.
|
||||
joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
|
||||
|
||||
|
||||
# unknow
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
|
||||
|
@ -359,7 +368,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# limit and offset
|
||||
@users = @users.limit(@user_pages.per_page).offset(@user_pages.offset)
|
||||
|
||||
|
||||
@user_base_tag = params[:id] ? 'base_users':'users_base'
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -369,7 +378,7 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def search
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
@ -413,8 +422,122 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def user_courses4show
|
||||
query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
|
||||
query = query.where("m.user_id = ?",@user.id).order("#{Course.table_name}.id desc")
|
||||
if User.current == @user #看自己
|
||||
else
|
||||
if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师
|
||||
query = query.joins("join member_roles r on m.id = r.member_id")
|
||||
query = query.where("r.role_id in(3,7,9)")
|
||||
end
|
||||
query = query.where(Course.table_name+".is_public = 1")
|
||||
end
|
||||
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where(" #{Course.table_name}.id < ?",params[:lastid],)
|
||||
end
|
||||
@list = query.limit(8)
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
def user_projects4show
|
||||
query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
|
||||
query = query.where("m.user_id = ? and #{Project.table_name}.project_type=?",@user.id,Project::ProjectType_project)
|
||||
if User.current == @user #看自己
|
||||
else
|
||||
query = query.where(Project.table_name+".is_public = 1")
|
||||
# TODO or exists (select 1 from project c2,members m2 where c2.id=m2.course_id and c2.id=#{Project.table_name}.id and m2.user_id= User.current.id)
|
||||
end
|
||||
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where("( (#{Project.table_name}.updated_on=? and #{Project.table_name}.id < ?) or #{Project.table_name}.updated_on<?)",params[:lasttime],params[:lastid],params[:lasttime])
|
||||
end
|
||||
@list = query.order("#{Project.table_name}.updated_on desc,#{Project.table_name}.id desc").limit(8).all
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
|
||||
def user_course_activities
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
lastid = params[:lastid];
|
||||
end
|
||||
|
||||
user_ids = []
|
||||
if @user == User.current
|
||||
watcher = User.watched_by(@user)
|
||||
watcher.push(User.current)
|
||||
user_ids = watcher.map{|x| x.id}
|
||||
else
|
||||
user_ids << @user.id
|
||||
end
|
||||
|
||||
query = Activity.joins("join courses c on c.id=#{Activity.table_name}.activity_container_id and #{Activity.table_name}.activity_container_type='Course'")
|
||||
query = query.where("#{Activity.table_name}.user_id in (?)", user_ids)
|
||||
if User.current != @user #看别人
|
||||
if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师
|
||||
query = query.joins("join members m on c.id=m.course_id and m.user_id = #{@user.id}")
|
||||
query = query.joins("join member_roles r on m.id = r.member_id")
|
||||
query = query.where("r.role_id in(3,7,9)")
|
||||
end
|
||||
query = query.where("c.is_public=1")
|
||||
end
|
||||
if(lastid != nil)
|
||||
query = query.where("#{Activity.table_name}.id < ?",lastid)
|
||||
end
|
||||
query = query.order("#{Activity.table_name}.id desc")
|
||||
@list = query_activities(query)
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
|
||||
def user_project_activities
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
lastid = params[:lastid];
|
||||
end
|
||||
|
||||
user_ids = []
|
||||
if @user == User.current
|
||||
watcher = User.watched_by(@user)
|
||||
watcher.push(User.current)
|
||||
user_ids = watcher.map{|x| x.id}
|
||||
else
|
||||
user_ids << @user.id
|
||||
end
|
||||
|
||||
query = Activity.joins("join projects c on c.id=#{Activity.table_name}.activity_container_id and #{Activity.table_name}.activity_container_type='Project'")
|
||||
query = query.where(user_id: user_ids)
|
||||
if User.current != @user #看别人
|
||||
query = query.where("c.is_public=1")
|
||||
end
|
||||
if(lastid != nil)
|
||||
query = query.where("#{Activity.table_name}.id < ?",lastid)
|
||||
end
|
||||
query = query.order("#{Activity.table_name}.id desc")
|
||||
@list = query_activities(query)
|
||||
|
||||
render :action=>'user_course_activities',:layout=>nil
|
||||
end
|
||||
|
||||
def user_feedback4show
|
||||
query = @user.journals_for_messages
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
query = query.where("#{JournalsForMessage.table_name}.id < ?",params[:lastid])
|
||||
end
|
||||
logger.info('xxoo')
|
||||
@list = query.order("#{JournalsForMessage.table_name}.id desc").limit(3).all
|
||||
logger.info('aavv')
|
||||
render :layout=>nil,:locals => {:feed_list=>@list}
|
||||
end
|
||||
|
||||
def show
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
def show_old
|
||||
pre_count = 10 #limit
|
||||
# Time 2015-02-04 11:46:34
|
||||
# Author lizanle
|
||||
|
@ -430,9 +553,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
when "2"
|
||||
message = []
|
||||
if @user == User.current
|
||||
if @user == User.current
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
end
|
||||
@activity_count = message.size
|
||||
@info_pages = Paginator.new @activity_count, pre_count, params['page']
|
||||
|
@ -463,7 +586,7 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids = []
|
||||
ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id}
|
||||
|
||||
|
@ -482,7 +605,7 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id}
|
||||
|
||||
#News
|
||||
|
@ -491,16 +614,16 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id}
|
||||
|
||||
project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
|
||||
c_ids = []
|
||||
Course.where(id: project_ids).each do |x|
|
||||
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
|
||||
end
|
||||
end
|
||||
ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id}
|
||||
|
||||
|
||||
#Message
|
||||
act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id}
|
||||
board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id}
|
||||
|
@ -508,14 +631,14 @@ class UsersController < ApplicationController
|
|||
p_ids = []
|
||||
Project.where(id: project_ids).each do |x|
|
||||
p_ids << x.id unless x.visible?(User.current)
|
||||
end
|
||||
end
|
||||
ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id}
|
||||
|
||||
|
||||
project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id}
|
||||
c_ids = []
|
||||
Course.where(id: project_ids).each do |x|
|
||||
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
|
||||
end
|
||||
end
|
||||
ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id}
|
||||
|
||||
logger.debug "filter ids #{ids}"
|
||||
|
@ -533,33 +656,33 @@ class UsersController < ApplicationController
|
|||
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
|
||||
# }
|
||||
#
|
||||
|
||||
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
|
||||
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
|
||||
@state = 0
|
||||
end
|
||||
|
||||
|
||||
if params[:user].present?
|
||||
|
||||
|
||||
user_temp = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{params[:user]}%' or lastname like '%#{params[:user]}%'")
|
||||
|
||||
|
||||
if user_temp.size > 1
|
||||
activity = Activity.where('user_id in (?)', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
activity = Activity.where('user_id in (?)', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
elsif user_temp.size == 1
|
||||
activity = Activity.where('user_id = ?', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
activity = Activity.where('user_id = ?', user_temp).where('user_id in (?)', watcher).order('id desc')
|
||||
else
|
||||
activity = Activity.where("1 = 0")
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@activity_count = activity.count
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
@offset ||= @activity_pages.offset
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
@state = 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
#Modified by nie
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
|
@ -581,17 +704,17 @@ class UsersController < ApplicationController
|
|||
def info
|
||||
|
||||
message = []
|
||||
if @user == User.current
|
||||
if @user == User.current
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@info_count = message.size
|
||||
@info_pages = Paginator.new @info_count, @limit, params['page']
|
||||
@offset ||= @info_pages.offset
|
||||
|
||||
|
||||
messages = message.sort {|x,y| y.created_on <=> x.created_on }
|
||||
|
||||
|
||||
@message = messages[@offset, @limit]
|
||||
|
||||
unless User.current.admin?
|
||||
|
@ -607,7 +730,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
#### end
|
||||
|
||||
|
||||
|
||||
def new
|
||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||
|
@ -665,7 +788,7 @@ class UsersController < ApplicationController
|
|||
@auth_sources = AuthSource.all
|
||||
@membership ||= Member.new
|
||||
end
|
||||
|
||||
|
||||
def watch_projects
|
||||
@watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', @user.id)
|
||||
@state = 1
|
||||
|
@ -835,42 +958,66 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
###add by huang
|
||||
def user_watchlist
|
||||
def user_watchlist
|
||||
limit = 10;
|
||||
query = User.watched_by(@user.id);
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
|
||||
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
||||
end
|
||||
###add by huang
|
||||
def user_fanslist
|
||||
|
||||
def user_fanslist
|
||||
limit = 10;
|
||||
query = @user.watcher_users;
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@action = 'fans'
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
|
||||
def user_visitorlist
|
||||
limit = 10;
|
||||
#query = @user.watcher_users;
|
||||
query = User.joins("join visitors v on #{User.table_name}.id=v.user_id")
|
||||
query = query.where("v.master_id=?",@user.id)
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("v.updated_on desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@action = 'visitor'
|
||||
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
||||
end
|
||||
|
||||
#william
|
||||
def update_extensions(user_extensions)
|
||||
user_extensions = params[:user_extensions]
|
||||
unless user_extensions.nil?
|
||||
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
|
||||
|
||||
|
||||
# user_extensions.
|
||||
end
|
||||
end
|
||||
|
||||
# added by bai
|
||||
def topic_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def project_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def activity_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def influence_score_index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def score_index
|
||||
|
||||
|
||||
end
|
||||
# end
|
||||
def topic_new_score_index
|
||||
|
@ -916,7 +1063,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# 必填自己的工作单位,其实就是学校
|
||||
def auth_user_extension
|
||||
if @user == User.current && @user.user_extensions.nil?
|
||||
if @user == User.current && @user.user_extensions.nil?
|
||||
flash[:error] = l(:error_complete_occupation)
|
||||
redirect_to my_account_url
|
||||
end
|
||||
|
@ -944,4 +1091,20 @@ class UsersController < ApplicationController
|
|||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
def recorded_visitor
|
||||
if(User.current.logged? && User.current != @user)
|
||||
#impl = Visitor.where('user_id=? and master_id=?',User.current.id,@user.id).find;
|
||||
# impl = Visitor.find_by_sql('user_id=? and master_id=?',[User.current.id,@user.id]);
|
||||
impl = Visitor.find_by_user_id_and_master_id(User.current.id,@user.id);
|
||||
if(impl.nil?)
|
||||
impl = Visitor.new
|
||||
impl.user_id = User.current.id
|
||||
impl.master_id = @user.id
|
||||
else
|
||||
impl.updated_on = Time.now
|
||||
end
|
||||
impl.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,12 +16,15 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
class WatchersController < ApplicationController
|
||||
before_filter :require_login#, :find_watchables, :only => [:watch, :unwatch]
|
||||
|
||||
helper :users
|
||||
|
||||
def watch
|
||||
s = WatchesService.new
|
||||
watchables = s.watch params.merge(:current_user_id => User.current.id)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables} }
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add'} }
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == "404"
|
||||
|
@ -37,7 +40,7 @@ class WatchersController < ApplicationController
|
|||
watchables = s.unwatch params.merge(:current_user_id => User.current.id)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables} }
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete'} }
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == "404"
|
||||
|
|
|
@ -100,44 +100,6 @@ class WelcomeController < ApplicationController
|
|||
@course_page = FirstPage.find_by_page_type('course')
|
||||
@school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
|
||||
@logoLink ||= logolink()
|
||||
|
||||
##3-8月份为查找春季课程,9-2月份为查找秋季课程
|
||||
#month_now = Time.now.strftime("%m").to_i
|
||||
#year_now = Time.new.strftime("%Y").to_i
|
||||
#(month_now >= 3 && month_now < 9) ? course_term = l(:label_spring) : course_term = l(:label_autumn)
|
||||
##year_now -= 1 if year_now < 3
|
||||
#@school_id.nil? ? @cur_school_course = [] : @cur_school_course = find_miracle_course(10,7,@school_id, year_now, course_term)
|
||||
##未登录或者当前学校未开设课程
|
||||
#if @cur_school_course.empty?
|
||||
# @has_course = false
|
||||
# User.current.logged? ? course_count = 9 : course_count = 10
|
||||
# @cur_school_course += find_all_new_hot_course(course_count, @school_id, year_now, course_term)
|
||||
# while @cur_school_course.count < 9 do
|
||||
# if course_term == l(:label_spring)
|
||||
# course_term = l(:label_autumn)
|
||||
# year_now -= 1
|
||||
# else
|
||||
# course_term = l(:label_spring)
|
||||
# end
|
||||
# @cur_school_course += find_all_new_hot_course((10-@cur_school_course.count), nil, year_now, course_term)
|
||||
# end
|
||||
#else
|
||||
# if @cur_school_course.count < 9
|
||||
# @has_course = false
|
||||
# @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, @school_id, year_now, course_term)
|
||||
# if @cur_school_course.count < 9
|
||||
# if course_term == l(:label_spring)
|
||||
# course_term = l(:label_autumn)
|
||||
# year_now -= 1
|
||||
# else
|
||||
# course_term = l(:label_spring)
|
||||
# end
|
||||
# @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, nil, year_now, course_term)
|
||||
# end
|
||||
# else
|
||||
# @has_course = true
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
def logolink()
|
||||
|
|
|
@ -4,7 +4,7 @@ class WordsController < ApplicationController
|
|||
include ApplicationHelper
|
||||
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
|
||||
def create
|
||||
if params[:new_form][:user_message].size>0
|
||||
if params[:new_form][:user_message].size>0 && User.current.logged?
|
||||
unless params[:user_id].nil?
|
||||
if params[:reference_content]
|
||||
message = params[:new_form][:user_message] + "\n" + params[:reference_content]
|
||||
|
@ -13,26 +13,18 @@ class WordsController < ApplicationController
|
|||
end
|
||||
refer_user_id = params[:new_form][:reference_user_id].to_i
|
||||
|
||||
@user.add_jour(User.current, message, refer_user_id)
|
||||
list = @user.add_jour(User.current, message, refer_user_id)
|
||||
unless refer_user_id == 0 || refer_user_id == User.current.id
|
||||
User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
|
||||
list = User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
|
||||
end
|
||||
@user.count_new_jour
|
||||
# if a_message.size > 5
|
||||
# @message = a_message[-5, 5]
|
||||
# else
|
||||
# @message = a_message
|
||||
# end
|
||||
# @message_count = a_message.count
|
||||
@jour = list.last
|
||||
end
|
||||
end
|
||||
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse
|
||||
@jour = paginateHelper @jours,10
|
||||
jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jour = paginateHelper jours,10
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,10 +80,10 @@ class WordsController < ApplicationController
|
|||
elsif @journal_destroyed.jour_type == "Principal"
|
||||
@user = User.find(@journal_destroyed.jour_id)
|
||||
@jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
@is_user = true
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -204,7 +196,15 @@ class WordsController < ApplicationController
|
|||
flash[:error] = feedback.errors.full_messages[0]
|
||||
redirect_to project_feedback_url(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
#给用户留言
|
||||
def leave_user_message
|
||||
@user = User.find(params[:id])
|
||||
if params[:new_form][:user_message].size>0 && User.current.logged? && @user
|
||||
@user.add_jour(User.current, params[:new_form][:user_message])
|
||||
end
|
||||
redirect_to feedback_path(@user)
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
|
|
|
@ -42,4 +42,33 @@ module ActivitiesHelper
|
|||
end
|
||||
sorted_events
|
||||
end
|
||||
|
||||
def get_container_type(activity)
|
||||
if activity.act.nil?
|
||||
return ['Unknow',0]
|
||||
end
|
||||
#问卷
|
||||
if activity.act_type == 'Poll'
|
||||
return ['Course',activity.act.polls_group_id]
|
||||
end
|
||||
#注册
|
||||
if activity.act_type == 'Principal'
|
||||
return ['Principal',activity.act.id]
|
||||
end
|
||||
#留言
|
||||
if activity.act_type == 'JournalsForMessage'
|
||||
return [activity.act.jour_type,activity.act.jour_id,activity.act.user_id]
|
||||
end
|
||||
|
||||
# HomeworkCommon Issue Journal Message News
|
||||
if activity.act.respond_to?('course') && activity.act.course
|
||||
return ['Course',activity.act.course.id]
|
||||
end
|
||||
if activity.act.respond_to?('project') && activity.act.project
|
||||
return ['Project',activity.act.project.id]
|
||||
end
|
||||
|
||||
# Contest Contestnotification
|
||||
return ['Unknow',0]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# encoding: utf-8
|
||||
module ApiHelper
|
||||
ONE_MINUTE = 60 * 1000
|
||||
ONE_HOUR = 60 * ONE_MINUTE
|
||||
ONE_DAY = 24 * ONE_HOUR
|
||||
ONE_MONTH = 30 * ONE_DAY
|
||||
|
||||
ONE_YEAR = 12 * ONE_MONTH
|
||||
#获取用户的工作单位
|
||||
def get_user_work_unit user
|
||||
work_unit = ""
|
||||
|
@ -66,7 +72,7 @@ module ApiHelper
|
|||
(user.language.nil? || user.language == "") ? 'zh':user.language
|
||||
end
|
||||
|
||||
# 获取课程作业的状态
|
||||
# 学生获取课程作业的状态
|
||||
def get_homework_status homework
|
||||
homework_status = ""
|
||||
if !homework.nil?
|
||||
|
@ -75,9 +81,9 @@ module ApiHelper
|
|||
when 1
|
||||
homework_status = show_homework_deadline homework
|
||||
when 2
|
||||
homework_status = "正在匿评中"
|
||||
homework_status = "正在匿评"
|
||||
when 3
|
||||
homework_status = "匿评已结束"
|
||||
homework_status = "匿评结束"
|
||||
end
|
||||
elsif homework.homework_type == 0
|
||||
homework_status = "未启用匿评"
|
||||
|
@ -163,5 +169,37 @@ module ApiHelper
|
|||
|
||||
end
|
||||
|
||||
# 获取当前时间
|
||||
def time_from_now time
|
||||
lastUpdateTime = time.to_i*1000
|
||||
|
||||
currentTime = Time.now.to_i*1000
|
||||
timePassed = currentTime - lastUpdateTime;
|
||||
timeIntoFormat = 0
|
||||
updateAtValue = ""
|
||||
if timePassed < 0
|
||||
updateAtValue = "时间有问题"
|
||||
elsif timePassed < ONE_MINUTE
|
||||
updateAtValue = "一分钟前"
|
||||
elsif timePassed < ONE_HOUR
|
||||
timeIntoFormat = timePassed / ONE_MINUTE
|
||||
updateAtValue = timeIntoFormat.to_s + "分钟前"
|
||||
elsif (timePassed < ONE_DAY)
|
||||
timeIntoFormat = timePassed / ONE_HOUR
|
||||
updateAtValue = timeIntoFormat.to_s + "小时前"
|
||||
elsif (timePassed < ONE_MONTH)
|
||||
timeIntoFormat = timePassed / ONE_DAY
|
||||
updateAtValue = timeIntoFormat.to_s + "天前"
|
||||
elsif (timePassed < ONE_YEAR)
|
||||
timeIntoFormat = timePassed / ONE_MONTH
|
||||
updateAtValue = timeIntoFormat.to_s + "个月前"
|
||||
else
|
||||
timeIntoFormat = timePassed / ONE_YEAR
|
||||
updateAtValue = timeIntoFormat.to_s + "年前"
|
||||
end
|
||||
updateAtValue
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -1812,7 +1812,7 @@ module ApplicationHelper
|
|||
#获取用户未过期的课程
|
||||
def get_user_course user
|
||||
courses_doing = []
|
||||
user.courses.each do |course|
|
||||
user.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course|
|
||||
if !course_endTime_timeout?(course)
|
||||
courses_doing.push course
|
||||
end
|
||||
|
@ -1824,7 +1824,9 @@ module ApplicationHelper
|
|||
def attachment_candown attachment
|
||||
candown = false
|
||||
if attachment.container
|
||||
if attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
|
||||
if attachment.container.class.to_s=="PhoneAppVersion"
|
||||
candown = true
|
||||
elsif attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
|
||||
project = attachment.container.project
|
||||
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif attachment.container.is_a?(Project)
|
||||
|
@ -1850,6 +1852,7 @@ module ApplicationHelper
|
|||
candown = true
|
||||
elsif attachment.container.class.to_s=="StudentWork"
|
||||
candown = true
|
||||
|
||||
elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses
|
||||
course = attachment.container.courses.first
|
||||
candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1)
|
||||
|
@ -2345,6 +2348,128 @@ module ApplicationHelper
|
|||
|
||||
#将文本内的/n转换为<br>
|
||||
def text_format text
|
||||
text.gsub("\n","<br/>").html_safe
|
||||
text.gsub("&","&").gsub("<","<").gsub(">",">").gsub("\n","<br/>").html_safe
|
||||
end
|
||||
|
||||
#评分规则显示
|
||||
def scoring_rules late_penalty,homework_id,is_teacher,absence_penalty=nil
|
||||
if absence_penalty
|
||||
if late_penalty.to_i == 0 && absence_penalty.to_i == 0
|
||||
notice = "尚未设置评分规则"
|
||||
if is_teacher
|
||||
notice += ",请 " + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
|
||||
end
|
||||
elsif late_penalty.to_i != 0 && absence_penalty.to_i == 0
|
||||
notice = "迟交扣#{late_penalty}分,缺评扣分未设置"
|
||||
elsif late_penalty.to_i == 0 && absence_penalty.to_i != 0
|
||||
notice = "迟交扣分未设置,缺评一个作品扣#{absence_penalty}分"
|
||||
elsif late_penalty.to_i != 0 && absence_penalty.to_i != 0
|
||||
notice = "迟交扣#{late_penalty}分,缺评一个作品扣#{absence_penalty}分"
|
||||
end
|
||||
else
|
||||
if late_penalty.to_i == 0
|
||||
notice = "尚未设置评分规则"
|
||||
if is_teacher
|
||||
notice += ",请 " + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
|
||||
end
|
||||
else
|
||||
notice = "迟交扣#{late_penalty}分"
|
||||
end
|
||||
end
|
||||
notice.html_safe
|
||||
end
|
||||
|
||||
#老师C语言的标准代码
|
||||
def c_stantard_code_teacher
|
||||
"// 老师您好!这是一个C语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <stdio.h> //引用必须头文件
|
||||
int main(int argc, char** argv) {
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
|
||||
printf(\"%d\",a+b); //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
|
||||
#老师C++语言的标准代码
|
||||
def c_stantard_code_teacher_
|
||||
"// 老师您好!这是一个C++语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <iostream> //引用必须头文件
|
||||
#include <cstdlib>
|
||||
using namespace std;
|
||||
int main(int argc, char** argv){
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
cout<<a+b; //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
|
||||
#学生C语言的标准代码
|
||||
def c_stantard_code_student
|
||||
"// 同学好!这是一个C语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <stdio.h> //引用必须头文件
|
||||
int main(int argc, char** argv) {
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
|
||||
printf(\"%d\",a+b); //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
|
||||
#学生C++语言的标准代码
|
||||
def c_stantard_code_student_
|
||||
"// 同学好!这是一个C++语言的样例程序
|
||||
// 程序功能:输入两个整数,输出两者之和
|
||||
// 测试集合:老师可以给出多组测试集,例如:
|
||||
// 输入1和2,输出3
|
||||
// 输入3和4,输出7
|
||||
// ... ...
|
||||
// 系统将根据您给出的测试集对学生代码进行自动评分
|
||||
|
||||
// 特别提醒:程序采用命令行传参方式,输入通过argv传入
|
||||
// 否则您的作业标准代码将不能通过测试
|
||||
|
||||
#include <iostream> //引用必须头文件
|
||||
#include <cstdlib>
|
||||
using namespace std;
|
||||
int main(int argc, char** argv){
|
||||
int a = atoi(argv[1]); //将第一个输入转成整型
|
||||
int b = atoi(argv[2]); //将第二个输入转换为整型
|
||||
cout<<a+b; //输出a+b
|
||||
return 0;
|
||||
}".html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
@ -676,4 +676,61 @@ module CoursesHelper
|
|||
end
|
||||
result
|
||||
end
|
||||
|
||||
#生成课程相关动态的链接
|
||||
def course_activity_link activity
|
||||
# activity = CourseActivity.first
|
||||
title = ""
|
||||
url = ""
|
||||
if activity.course_act
|
||||
case activity.course_act_type
|
||||
when "Course"
|
||||
title = activity.course_act.name
|
||||
url = course_path activity.course
|
||||
when "HomeworkCommon"
|
||||
title = "作业 " + activity.course_act.name
|
||||
url = student_work_index_path(:homework => activity.course_act.id)
|
||||
when "News"
|
||||
title = "通知公告 " + activity.course_act.title
|
||||
url = course_news_index_path(activity.course)
|
||||
when "Attachment"
|
||||
title = "课件 " + activity.course_act.filename
|
||||
url = course_files_path(activity.course)
|
||||
when "Message"
|
||||
title = "课程讨论区 " + activity.course_act.subject
|
||||
url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id)
|
||||
when "JournalsForMessage"
|
||||
title = "留言 " + activity.course_act.notes
|
||||
url = course_feedback_path(activity.course)
|
||||
when "Poll"
|
||||
title = "问卷 " + activity.course_act.polls_name
|
||||
url = poll_path(activity.course_act_id)
|
||||
end
|
||||
end
|
||||
link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
|
||||
end
|
||||
|
||||
#课程动态的描述
|
||||
def course_activity_desc activity
|
||||
desc = ""
|
||||
if activity.course_act
|
||||
case activity.course_act_type
|
||||
when "Course"
|
||||
desc = ""
|
||||
when "HomeworkCommon"
|
||||
desc = activity.course_act.description
|
||||
when "News"
|
||||
desc = activity.course_act.description
|
||||
when "Attachment"
|
||||
desc = ""
|
||||
when "Message"
|
||||
desc = activity.course_act.content
|
||||
when "JournalsForMessage"
|
||||
desc = ""
|
||||
when "Poll"
|
||||
desc = activity.course_act.polls_description
|
||||
end
|
||||
end
|
||||
desc.html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,19 @@ 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 = []
|
||||
|
@ -53,31 +66,31 @@ module HomeworkCommonHelper
|
|||
link
|
||||
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
|
||||
#将状态转换为错误信息
|
||||
def status_to_err_msg status
|
||||
case status.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
'输入和输出不匹配'
|
||||
when -3
|
||||
'输入和输出不匹配'
|
||||
when 1
|
||||
'运行出错'
|
||||
when 2
|
||||
'超时'
|
||||
when 3
|
||||
'内存超出'
|
||||
when 4
|
||||
'输出超出'
|
||||
when 5
|
||||
'禁用函数'
|
||||
when 6
|
||||
'其他错误'
|
||||
when 0
|
||||
'成功'
|
||||
else
|
||||
notice = "迟交扣#{late_penalty}分"
|
||||
end
|
||||
'未知错误'
|
||||
end
|
||||
notice.html_safe
|
||||
end
|
||||
end
|
|
@ -38,7 +38,7 @@ module MembersHelper
|
|||
scope = []
|
||||
end
|
||||
principals = paginateHelper scope,10
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5')
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
|
||||
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true
|
||||
}
|
||||
|
|
|
@ -74,4 +74,13 @@ module PollHelper
|
|||
end
|
||||
end
|
||||
|
||||
#带勾选框的问卷列表
|
||||
def poll_check_box_tags(name,polls,current_poll)
|
||||
s = ''
|
||||
polls.each do |poll|
|
||||
s << "<label>#{ check_box_tag name, poll.id, false, :id => nil } #{h poll.polls_name.blank? ? l(:label_poll_new) : poll.polls_name } [#{ h Course.find(poll.polls_group_id).name}]</label><br/>"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
end
|
|
@ -20,9 +20,9 @@ module PraiseTreadHelper
|
|||
# when 0
|
||||
# return @record.tread_num.nil? ? 0 : @record.tread_num
|
||||
# end
|
||||
return (@record.praise_num.to_i-@record.tread_num.to_i)
|
||||
return ((@record.praise_num.nil? ? 0 : @record.praise_num.to_i)-(@record.tread_num.nil? ? 0 : @record.tread_num.to_i))
|
||||
else
|
||||
return 0
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -236,13 +236,14 @@ module RepositoriesHelper
|
|||
# 判断项目是否有主版本库
|
||||
def judge_main_repository(pro)
|
||||
if pro.repositories.blank?
|
||||
return false
|
||||
status = false
|
||||
else
|
||||
pro.repositories.sort.each do |rep|
|
||||
rep.is_default?
|
||||
return true
|
||||
pro.repositories.each do |rep|
|
||||
status = true and break if rep.is_default?
|
||||
status = false
|
||||
end
|
||||
end
|
||||
status
|
||||
end
|
||||
# def cvs_field_tags(form, repository)
|
||||
# content_tag('p', form.text_field(
|
||||
|
|
|
@ -303,4 +303,207 @@ module UsersHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_watcher_users(obj)
|
||||
count = User.watched_by(obj.id).count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all
|
||||
return [count,list];
|
||||
end
|
||||
|
||||
def get_fans_users(obj)
|
||||
count = obj.watcher_users.count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
|
||||
return [count,list];
|
||||
end
|
||||
|
||||
def get_visitor_users(obj)
|
||||
query = Visitor.where("master_id=?",obj.id)
|
||||
count = query.count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = query.order("updated_on desc").limit(10).all
|
||||
return [count,list]
|
||||
end
|
||||
|
||||
def get_create_course_count(user)
|
||||
user.courses.visible.where("tea_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#获取加入课程数
|
||||
def get_join_course_count(user)
|
||||
user.courses.visible.count - get_create_course_count(user)
|
||||
end
|
||||
|
||||
#发布作业数
|
||||
def get_homework_commons_count(user)
|
||||
HomeworkCommon.where("user_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#资源数
|
||||
def get_projectandcourse_attachment_count(user)
|
||||
Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
|
||||
end
|
||||
|
||||
#创建项目数
|
||||
def get_create_project_count(user)
|
||||
user.projects.visible.where("projects.user_id=#{user.id}").count
|
||||
end
|
||||
|
||||
#加入项目数
|
||||
def get_join_project_count(user)
|
||||
user.projects.visible.count - get_create_project_count(user)
|
||||
end
|
||||
|
||||
#创建缺陷数
|
||||
def get_create_issue_count(user)
|
||||
Issue.where("author_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#解决缺陷数
|
||||
def get_resolve_issue_count(user)
|
||||
Issue.where("assigned_to_id = ? and status_id=3",user.id).count
|
||||
end
|
||||
|
||||
#参与匿评数
|
||||
def get_anonymous_evaluation_count(user)
|
||||
StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
|
||||
end
|
||||
|
||||
def query_activities(query)
|
||||
list = query.limit(13).all
|
||||
result = []
|
||||
for item in list
|
||||
container = get_activity_container(item)
|
||||
result << { :item=>item,:e=>container }
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def get_activity_container activity
|
||||
return activity.activity_container
|
||||
end
|
||||
|
||||
def get_activity_act_showname_htmlclear(activity)
|
||||
str = get_activity_act_showname(activity)
|
||||
str = str.gsub(/<.*>/,'')
|
||||
str = str.gsub(/\r/,'')
|
||||
str = str.gsub(/\n/,'')
|
||||
str = str.lstrip.rstrip
|
||||
if str == ''
|
||||
str = 'RE:'
|
||||
end
|
||||
return str.html_safe
|
||||
end
|
||||
|
||||
def get_activity_act_showname(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
return activity.act.name
|
||||
when "Issue"
|
||||
return activity.act.subject
|
||||
when "Journal"
|
||||
arr = details_to_strings(activity.act.details,true)
|
||||
arr << activity.act.notes
|
||||
str = ''
|
||||
arr.each { |item| str = str+item }
|
||||
return str
|
||||
when "JournalsForMessage"
|
||||
return activity.act.notes
|
||||
when "Message"
|
||||
return activity.act.subject
|
||||
when "News"
|
||||
return activity.act.title
|
||||
when "Poll"
|
||||
return activity.act.polls_name
|
||||
when "Contest"
|
||||
return ''
|
||||
when "Contestnotification"
|
||||
return ''
|
||||
when "Principal"
|
||||
return ''
|
||||
else
|
||||
return activity.act_type
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_act_createtime(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
return activity.act.created_at
|
||||
when "Poll"
|
||||
return activity.act.created_at
|
||||
else
|
||||
return activity.act.created_on
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_container_url e
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
end
|
||||
|
||||
if e.class.to_s == 'Course'
|
||||
return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course)
|
||||
end
|
||||
return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name)
|
||||
end
|
||||
|
||||
def get_activity_url(activity,e)
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
end
|
||||
|
||||
case activity.act_type
|
||||
# when "Contest"
|
||||
# when "Contestnotification"
|
||||
# when "Principal"
|
||||
when "HomeworkCommon"
|
||||
return homework_common_index_path( :course=>e.id )
|
||||
when "Issue"
|
||||
return issue_path(activity.act.id)
|
||||
when "Journal"
|
||||
return issue_path( activity.act.journalized_id )
|
||||
when "JournalsForMessage"
|
||||
return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e)
|
||||
when "Message"
|
||||
return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e)
|
||||
when "News"
|
||||
return news_path(activity.act)
|
||||
#return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e)
|
||||
when "Poll"
|
||||
return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s )
|
||||
else
|
||||
return 'javascript:;'
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_opt(activity,e)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
return '创建了作业'
|
||||
when "News"
|
||||
return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻'
|
||||
when "Issue"
|
||||
return '发表了问题'
|
||||
when "Journal"
|
||||
return '更新了问题'
|
||||
when "JournalsForMessage"
|
||||
return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈'
|
||||
#return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : ''
|
||||
when "Message"
|
||||
return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子'
|
||||
when "Poll"
|
||||
return '创建了问卷'
|
||||
else
|
||||
return '有了新动态'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,9 +2,23 @@ class Activity < ActiveRecord::Base
|
|||
attr_accessible :act_id, :act_type, :user_id
|
||||
belongs_to :act, :polymorphic => true
|
||||
belongs_to :user
|
||||
belongs_to :activity_container, polymorphic: true
|
||||
validates :act_id, presence: true
|
||||
validates :act_type, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
include Trustie::Cache::ClearCourseEvent
|
||||
|
||||
before_create :set_container_type_val
|
||||
|
||||
#helper :activities
|
||||
include ActivitiesHelper
|
||||
def set_container_type_val
|
||||
params =get_container_type(self)
|
||||
self.activity_container_type = params[0]
|
||||
self.activity_container_id = params[1]
|
||||
if(self.act_type == 'JournalsForMessage')
|
||||
self.user_id = params[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,8 @@ class Attachment < ActiveRecord::Base
|
|||
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# end
|
||||
include UserScoreHelper
|
||||
|
||||
|
@ -71,8 +73,8 @@ class Attachment < ActiveRecord::Base
|
|||
cattr_accessor :thumbnails_storage_path
|
||||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
|
||||
before_save :files_to_final_location,:act_as_course_activity
|
||||
after_create :office_conver, :be_user_score,:act_as_forge_activity
|
||||
after_update :office_conver, :be_user_score
|
||||
after_destroy :delete_from_disk,:down_user_score
|
||||
|
||||
|
@ -552,4 +554,10 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.container_type == "Course" && self.course_acts.empty?
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,6 +33,11 @@ class Course < ActiveRecord::Base
|
|||
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
||||
|
||||
has_many :course_groups, :dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
||||
has_many :course_activities
|
||||
has_many :course_messages
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
|
@ -44,7 +49,7 @@ class Course < ActiveRecord::Base
|
|||
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
|
||||
validates_length_of :description, :maximum => 10000
|
||||
before_save :self_validate
|
||||
after_create :create_board_sync
|
||||
after_create :create_board_sync, :act_as_course_activity
|
||||
before_destroy :delete_all_members
|
||||
|
||||
safe_attributes 'extra',
|
||||
|
@ -310,6 +315,11 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
|
||||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
#def name
|
||||
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class CourseActivity < ActiveRecord::Base
|
||||
attr_accessible :user_id, :course_act_id,:course_act_type,:course_id
|
||||
# 虚拟关联
|
||||
belongs_to :course_act ,:polymorphic => true
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed
|
||||
|
||||
# 多态 虚拟关联
|
||||
belongs_to :course_message ,:polymorphic => true
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
validates :user_id,presence: true
|
||||
validates :course_id,presence: true
|
||||
validates :course_message_id,presence: true
|
||||
validates :course_message_type, presence: true
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class Dts < ActiveRecord::Base
|
||||
attr_accessible :Category, :Defect, :Description, :File, :IPLine, :IPLineCode, :Method, :Num, :PreConditions, :Review, :StartLine, :TraceInfo, :Variable, :project_id
|
||||
|
||||
belongs_to :project
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
class ForgeMessage < ActiveRecord::Base
|
||||
# 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT
|
||||
TYPE_OF_ISSUE_ACT = "Issue"
|
||||
TYPE_OF_MESSAGE_ACT = "Message"
|
||||
TYPE_OF_ATTACHMENT_ACT = "Attachment"
|
||||
TYPE_OF_DOCUMENT_ACT = "Document"
|
||||
TYPE_OF_JOURNAL_ACT = "Journal"
|
||||
TYPE_OF_WIKI_ACT = "Wiki"
|
||||
TYPE_OF_NEWS_ACT = "News"
|
||||
|
||||
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed
|
||||
|
||||
belongs_to :forge_message ,:polymorphic => true
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
validates :user_id,presence: true
|
||||
validates :project_id,presence: true
|
||||
validates :forge_message_id,presence: true
|
||||
validates :forge_message_type, presence: true
|
||||
end
|
|
@ -13,17 +13,40 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
has_many :student_works, :dependent => :destroy
|
||||
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
acts_as_attachable
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
|
||||
:description => :description,
|
||||
:author => :author,
|
||||
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
|
||||
after_create :act_as_activity, :send_mail
|
||||
after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.user_id)
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程作业消息记录
|
||||
def act_as_course_message
|
||||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#删除对应的图片
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class HomeworkTest < ActiveRecord::Base
|
||||
attr_accessible :input, :output, :homework_common_id
|
||||
attr_accessible :input, :output, :homework_common_id,:result,:error_msg
|
||||
|
||||
belongs_to :homework_common
|
||||
has_one :student_work_test
|
||||
has_many :student_work_test
|
||||
end
|
||||
|
|
|
@ -49,6 +49,8 @@ class Issue < ActiveRecord::Base
|
|||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# end
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
# ForgeMessage虚拟关联(多态)
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
|
||||
|
||||
|
||||
acts_as_nested_set :scope => 'root_id', :dependent => :destroy
|
||||
|
@ -80,7 +82,7 @@ class Issue < ActiveRecord::Base
|
|||
attr_reader :current_journal
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
# after_create :be_user_score
|
||||
|
@ -138,6 +140,16 @@ class Issue < ActiveRecord::Base
|
|||
:project_id => self.project_id)
|
||||
end
|
||||
# end
|
||||
|
||||
# 发布缺陷forge_messages中添加记录
|
||||
def act_as_forge_message
|
||||
# 指派给自己的缺陷不提示消息
|
||||
unless self.author_id == self.assigned_to_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id,
|
||||
:project_id => self.project_id,
|
||||
:viewed => false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||
|
@ -235,9 +247,10 @@ class Issue < ActiveRecord::Base
|
|||
base_reload(*args)
|
||||
end
|
||||
|
||||
def to_param
|
||||
@to_param ||= "#{id}_#{self.project.name}(#{self.project.issues.index(self).to_i+1}-#{self.project.issues.count})"#.parameterize
|
||||
end
|
||||
# 之所以注释是以为最终以id形式显示,另外如果项目名称带点号或者纯数字会出现问题
|
||||
# def to_param
|
||||
# @to_param ||= "#{id}_#{self.project.name}(#{self.project.issues.index(self).to_i+1}-#{self.project.issues.count})"#.parameterize
|
||||
# end
|
||||
|
||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||
def available_custom_fields
|
||||
|
|
|
@ -29,6 +29,8 @@ class Journal < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 被ForgeMessage虚拟关联
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
|
||||
# end
|
||||
attr_accessor :indice
|
||||
|
||||
|
@ -48,7 +50,7 @@ class Journal < ActiveRecord::Base
|
|||
before_create :split_private_notes
|
||||
|
||||
# fq
|
||||
after_save :act_as_activity,:be_user_score,:act_as_forge_activity
|
||||
after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message
|
||||
# end
|
||||
#after_destroy :down_user_score
|
||||
#before_save :be_user_score
|
||||
|
@ -163,10 +165,17 @@ class Journal < ActiveRecord::Base
|
|||
# Description 公共表中需要保存一份该记录
|
||||
def act_as_forge_activity
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.user_id,
|
||||
:project_id => self.issue.project.id)
|
||||
:project_id => self.issue.project.id)
|
||||
|
||||
end
|
||||
|
||||
# 缺陷状态更改,消息提醒
|
||||
def act_as_forge_message
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id,
|
||||
:project_id => self.issue.project_id,
|
||||
:viewed => false)
|
||||
end
|
||||
|
||||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
|
|
|
@ -56,9 +56,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
acts_as_attachable
|
||||
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
||||
validates :notes, presence: true, if: :is_homework_jour?
|
||||
after_create :act_as_activity #huang
|
||||
after_create :act_as_activity, :act_as_course_activity
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
@ -177,4 +179,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,7
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.jour_type == 'Course'
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -388,7 +388,8 @@ class Mailer < ActionMailer::Base
|
|||
@user = applied.user
|
||||
recipients = @project.manager_recipients
|
||||
s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
|
||||
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
|
||||
@token = Token.get_token_from_user(@user, 'autologin')
|
||||
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members', :token => @token.value)
|
||||
mail :to => recipients,
|
||||
:subject => s
|
||||
end
|
||||
|
|
|
@ -32,7 +32,12 @@ class Message < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# end
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
|
@ -68,7 +73,7 @@ class Message < ActiveRecord::Base
|
|||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
|
||||
|
||||
after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail
|
||||
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_course_message, :send_mail
|
||||
#before_save :be_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -185,6 +190,61 @@ class Message < ActiveRecord::Base
|
|||
:project_id => self.board.project.id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
# 课程讨论区添加消息
|
||||
# 老师发帖所有人都能收到消息
|
||||
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
|
||||
# 帖子被回复的可以收到消息通知
|
||||
def act_as_course_message
|
||||
if self.course
|
||||
if self.parent_id.nil? #主贴
|
||||
self.course.members.each do |m|
|
||||
if self.author.allowed_to?(:as_teacher, self.course) # 老师
|
||||
if m.user_id != self.author_id # 自己的帖子不给自己发送消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
else # 回帖
|
||||
#if self.author.allowed_to?(:as_teacher, self.course) # 老师
|
||||
self.course.members.each do |m|
|
||||
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
# if self.author.allowed_to?(:as_teacher, self.course) # 如果发帖人是老师
|
||||
# self.course.members.each do |m|
|
||||
# if self.parent_id.nil? # 主贴
|
||||
# if m.user_id != self.author_id # 自己的帖子不给自己发送消息
|
||||
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# else # 回帖只针对主贴发送消息
|
||||
# if m.user_id == Message.find(self.parent_id).author_id
|
||||
# self.course_messages << CourseMessage.new(:user_id => self.parent_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else # 学生只针对主贴回复
|
||||
# unless self.parent_id.nil?
|
||||
# self.course.members.each do |m|
|
||||
# if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
|
|
|
@ -28,7 +28,12 @@ class News < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# 被ForgeActivity虚拟关联
|
||||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# end
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
|
@ -49,7 +54,7 @@ class News < ActiveRecord::Base
|
|||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
|
||||
after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail
|
||||
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_course_messge, :add_author_as_watcher, :send_mail
|
||||
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
|
@ -121,6 +126,25 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程通知 消息发送
|
||||
#消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
|
||||
def act_as_course_messge
|
||||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
# Description 删除news后删除对应的资源
|
||||
|
@ -132,4 +156,4 @@ class News < ActiveRecord::Base
|
|||
Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -8,7 +8,12 @@ class Poll < ActiveRecord::Base
|
|||
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
||||
# 添加课程的poll动态
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
after_create :act_as_activity
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
after_create :act_as_activity, :act_as_course_activity
|
||||
# 课程消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
|
||||
:description => :polls_description,
|
||||
|
@ -27,4 +32,26 @@ class Poll < ActiveRecord::Base
|
|||
self.acts << Activity.new(:user_id => self.user_id)
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.polls_type == "Course"
|
||||
if self.polls_status == 2 #问卷是发布状态
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
|
||||
elsif self.polls_status == 1 #问卷是新建状态
|
||||
self.course_acts.destroy_all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 发布问卷,出了发布者外,其他人都能收到消息通知
|
||||
def act_as_course_message
|
||||
if self.polls_type == "Course"
|
||||
Course.find(self.polls_group_id).members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -68,6 +68,7 @@ class Project < ActiveRecord::Base
|
|||
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
|
||||
has_many :applied_projects
|
||||
has_many :invite_lists
|
||||
has_one :dts
|
||||
|
||||
# end
|
||||
#ADDED BY NIE
|
||||
|
@ -90,6 +91,8 @@ class Project < ActiveRecord::Base
|
|||
|
||||
has_many :tags, :through => :project_tags, :class_name => 'Tag'
|
||||
has_many :project_tags, :class_name => 'ProjectTags'
|
||||
# 关联虚拟表
|
||||
has_many :forge_messages
|
||||
|
||||
belongs_to :organization
|
||||
|
||||
|
|
|
@ -38,6 +38,12 @@ class Repository::Git < Repository
|
|||
'Git'
|
||||
end
|
||||
|
||||
def commits(authors, start_date, end_date, branch='master')
|
||||
scm.commits(authors, start_date, end_date,branch).map {|commit|
|
||||
[commit[:author], commit[:num]]
|
||||
}
|
||||
end
|
||||
|
||||
def report_last_commit
|
||||
extra_report_last_commit
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class StudentWork < ActiveRecord::Base
|
|||
has_many :student_works_evaluation_distributions, :dependent => :destroy
|
||||
has_many :student_works_scores, :dependent => :destroy
|
||||
belongs_to :project
|
||||
has_one :student_work_test
|
||||
has_many :student_work_test
|
||||
|
||||
before_destroy :delete_praise
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# encoding: utf-8
|
||||
class StudentWorkTest < ActiveRecord::Base
|
||||
attr_accessible :student_work_id, :homework_test_id
|
||||
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
|
||||
case self.result.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
|
@ -33,7 +33,7 @@ class StudentWorkTest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def test_score
|
||||
if self.result == 0
|
||||
if self.result.to_i == 0
|
||||
format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count)
|
||||
else
|
||||
0
|
||||
|
|
|
@ -109,7 +109,6 @@ class User < Principal
|
|||
has_many :contests, :foreign_key => 'author_id', :dependent => :destroy
|
||||
has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
|
||||
has_many :journal_replies, :dependent => :destroy
|
||||
has_many :activities, :dependent => :destroy
|
||||
has_many :students_for_courses
|
||||
|
@ -128,8 +127,15 @@ class User < Principal
|
|||
has_many :messages, :foreign_key => 'author_id'
|
||||
has_one :user_score, :dependent => :destroy
|
||||
has_many :documents # 项目中关联的文档再次与人关联
|
||||
# 关联虚拟表
|
||||
has_many :forge_messages
|
||||
has_many :course_messages
|
||||
# end
|
||||
|
||||
# 虚拟转换
|
||||
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
|
||||
has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"'
|
||||
has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"'
|
||||
# 邮件邀请状态
|
||||
# has_many :invite_lists
|
||||
# end
|
||||
|
@ -235,6 +241,28 @@ class User < Principal
|
|||
|
||||
# ======================================================================
|
||||
|
||||
# 查询用户未读过的记录
|
||||
# 用户留言记录
|
||||
def count_new_jour
|
||||
count = self.new_jours.count
|
||||
# count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count
|
||||
end
|
||||
|
||||
# 查询指派给我的缺陷记录
|
||||
def count_new_issue_assign_to
|
||||
self.issue_assigns
|
||||
end
|
||||
|
||||
# 新消息统计
|
||||
def count_new_message
|
||||
count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count
|
||||
end
|
||||
# 查询指派给我的缺陷记录
|
||||
def issue_status_update
|
||||
self.status_updates
|
||||
end
|
||||
# end
|
||||
|
||||
def extensions
|
||||
self.user_extensions ||= UserExtensions.new
|
||||
end
|
||||
|
@ -258,7 +286,7 @@ class User < Principal
|
|||
###添加留言 fq
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true)
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true, :is_readed => false)
|
||||
else
|
||||
jfm = self.journals_for_messages.build(options)
|
||||
jfm.save
|
||||
|
@ -291,11 +319,7 @@ class User < Principal
|
|||
name
|
||||
end
|
||||
## end
|
||||
|
||||
def count_new_jour
|
||||
count = self.new_jours.count
|
||||
end
|
||||
|
||||
|
||||
#added by nie
|
||||
def count_new_journal_reply
|
||||
count = self.journal_reply.count
|
||||
|
@ -418,7 +442,7 @@ class User < Principal
|
|||
end
|
||||
|
||||
def nickname(formatter = nil)
|
||||
login
|
||||
login.nil? || (login && login.empty?) ? "AnonymousUser" : login
|
||||
end
|
||||
|
||||
def name(formatter = nil)
|
||||
|
|
|
@ -12,6 +12,8 @@ class UserExtensions < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :school, :class_name => 'School', :foreign_key => :school_id
|
||||
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id
|
||||
validates_length_of :description, :maximum => 255
|
||||
validates_length_of :brief_introduction, :maximum => 255
|
||||
TEACHER = 0
|
||||
STUDENT = 1
|
||||
ENTERPRISE = 2
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class Visitor < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
end
|
|
@ -654,37 +654,42 @@ class CoursesService
|
|||
return
|
||||
end
|
||||
if current_user == @user || current_user.admin?
|
||||
membership = @user.coursememberships.page(1).per(15)
|
||||
membership = @user.coursememberships
|
||||
else
|
||||
membership = @user.coursememberships.page(1).per(15).all(:conditions => Course.visible_condition(current_user))
|
||||
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
|
||||
end
|
||||
if membership.nil? || membership.count == 0
|
||||
raise l(:label_no_courses, :locale => get_user_language(current_user))
|
||||
end
|
||||
membership.sort! { |older, newer| newer.created_on <=> older.created_on }
|
||||
#membership.sort! { |older, newer| newer.created_on <=> older.created_on }
|
||||
|
||||
#定义一个数组集合,存放hash数组,该hash数组包括课程的信息,并包含课程的最新发布的资源,最新的讨论区留言,最新的作业,最新的通知
|
||||
result = []
|
||||
#对用户所有的课程进行循环,找到每个课程最新发布的资源,最新的讨论区留言,最新的作业,最新的通知,并存进数组
|
||||
|
||||
membership.each do |mp|
|
||||
course = mp.course
|
||||
latest_course_dynamics = []
|
||||
notices_count = 0
|
||||
topic_count = 0
|
||||
topics = nil
|
||||
homeworkss = nil
|
||||
notices = nil
|
||||
|
||||
# 课程通知
|
||||
latest_news = course.news.page(1).per(2).order("created_on desc")
|
||||
unless latest_news.first.nil?
|
||||
latest_course_dynamics << {:type => 1, :time => latest_news.first.created_on,:count=>course.news.count,
|
||||
:news => latest_news.all}
|
||||
notices_count = course.news.count
|
||||
notices = latest_news.all
|
||||
latest_course_dynamics << {:time => latest_news.first.created_on }
|
||||
end
|
||||
|
||||
# 课程讨论区
|
||||
# latest_message = course.boards.first.topics.page(1).per(2)
|
||||
# unless latest_message.first.nil?
|
||||
# latest_course_dynamics << {:type => 2, :time => latest_message.first.created_on, :count =>course.boards.nil? ? 0 : course.boards.first.topics.count,
|
||||
# :topics => latest_message.all}
|
||||
# dynamics_count += 1
|
||||
# end
|
||||
|
||||
latest_message = course.boards.first.topics.page(1).per(2)
|
||||
unless latest_message.first.nil?
|
||||
topic_count = course.boards.nil? ? 0 : course.boards.first.topics.count
|
||||
topics = latest_message.all
|
||||
latest_course_dynamics << {:time => latest_message.first.created_on}
|
||||
end
|
||||
# 课程资源
|
||||
# latest_attachment = course.attachments.order("created_on desc").page(1).per(2)
|
||||
# unless latest_attachment.first.nil?
|
||||
|
@ -695,14 +700,17 @@ class CoursesService
|
|||
#课程作业 已经交的学生列表(暂定显示6人),未交的学生列表,作业的状态
|
||||
homeworks = course.homework_commons.page(1).per(2).order('created_at desc')
|
||||
unless homeworks.first.nil?
|
||||
latest_course_dynamics << {:type => 4, :time => homeworks.first.updated_at, :count=>course.homework_commons.count , :homeworks => homeworks}
|
||||
homeworkss = homeworks
|
||||
latest_course_dynamics << {:time => homeworks.first.updated_at}
|
||||
end
|
||||
latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
# 课程学霸 学生总分数排名靠前的5个人
|
||||
homework_count = course.homework_commons.count
|
||||
sql = "select users.*,ROUND(sum(student_works.final_score),2) score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{course.id}) GROUP BY student_works.user_id ORDER BY score desc limit 0,4"
|
||||
|
||||
better_students = User.find_by_sql(sql)
|
||||
|
||||
# 找出在课程讨论区发帖回帖数最多的
|
||||
active_students = []
|
||||
sql1 = " select users.*,count(author_id)*2 active_count from messages " <<
|
||||
|
@ -711,20 +719,41 @@ class CoursesService
|
|||
" 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=>Time.now.to_s,:count=> 4,:better_students=> better_students}
|
||||
latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"}
|
||||
end
|
||||
unless active_students.empty?
|
||||
latest_course_dynamics <<{:type=> 7,:time=>Time.now.to_s,:count=> 4,:active_students=>active_students}
|
||||
latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"}
|
||||
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) << "前"}
|
||||
result << {:course_name => course.name,
|
||||
:current_user_is_member => current_user.member_of_course?(course),
|
||||
:current_user_is_teacher => is_course_teacher(current_user,course),
|
||||
:course_id => course.id,
|
||||
:course_img_url => url_to_avatar(course),
|
||||
:course_time => course.time,
|
||||
:course_term => course.term,
|
||||
:news_count => notices_count,
|
||||
:homework_count => homework_count,
|
||||
:topic_count => topic_count,
|
||||
:news => notices,
|
||||
:homeworks => homeworkss,
|
||||
:topics => topics,
|
||||
:better_students => better_students,
|
||||
:active_students => active_students,
|
||||
:message => "",
|
||||
:course_student_num=>course ? course.members.count : 0,
|
||||
#:time_from_now=> distance_of_time_in_words(Time.now, latest_course_dynamic[:time].to_time) << "前",
|
||||
:time_from_now=>time_from_now(latest_course_dynamic[:time].to_time), #.strftime('%Y-%m-%d %H:%M:%S').to_s,
|
||||
:time=>latest_course_dynamic[:time].to_time}
|
||||
end
|
||||
|
||||
end
|
||||
#返回数组集合
|
||||
result.sort! { |order, newer| newer[:update_time] <=> order[:update_time] }
|
||||
result.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
@ -760,7 +789,7 @@ class CoursesService
|
|||
|
||||
# 获取某次作业的所有作业列表
|
||||
def student_work_list params,current_user
|
||||
is_teacher = User.current.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
is_teacher = current_user.allowed_to?(:as_teacher,Course.find(params[:course_id]))
|
||||
homework = HomeworkCommon.find(params[:homework_id])
|
||||
student_works = []
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
|
@ -788,6 +817,45 @@ class CoursesService
|
|||
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
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<div class="box tabular">
|
||||
<p>
|
||||
<label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||
<%= text_field_tag 'mail', nil, :size => 40 %>
|
||||
<%= text_field_tag 'mail', nil, :size => 40, :placeholder => '请输入注册邮箱'%>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<div class="tabs">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_forum), {:action => 'messages_list'}, class: "#{current_page?(messages_list_path)? 'selected' : nil }" %></li>
|
||||
<li><%= link_to l(:label_borad_course), {:action => 'course_messages'}, class: "#{current_page?(course_messages_path)? 'selected' : nil }" %></li>
|
||||
<li><%= link_to l(:label_borad_project), {:action => 'project_messages'}, class: "#{current_page?(project_messages_path)? 'selected' : nil }" %></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,66 @@
|
|||
<h3>
|
||||
<%=l(:label_message_plural)%>
|
||||
</h3>
|
||||
|
||||
<%= render 'tab_messages' %>
|
||||
<h4><%=l(:label_borad_course) %></h4>
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for course in @course_ms -%>
|
||||
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= Board.where('id=?',course.board_id).first.course_id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if course.try(:author).try(:realname) == ' '%><%= course.try(:author)%><% else %><%=course.try(:author).try(:realname) %><% end %>'>
|
||||
<% if course.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(course.try(:author), user_path(course.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(course.try(:author).try(:realname), user_path(course.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(course.created_on) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=course.subject %>'>
|
||||
<%= course.subject %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=course.replies_count %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
|
@ -0,0 +1,62 @@
|
|||
<h3>
|
||||
<%=l(:label_user_homework)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
作业名称
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
课程名称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
提交作品数
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
提交截止日期
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%@count=0 %>
|
||||
<% for homework in @homework do %>
|
||||
<% @count+=1 %>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<%=@count %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=homework.name%>'>
|
||||
<%=link_to(homework.name, student_work_index_path(:homework => homework.id))%>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=homework.course.name%>'>
|
||||
<%= link_to(homework.course.name, course_path(homework.course.id)) %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if homework.try(:user).try(:realname) == ' '%><%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'>
|
||||
<% if homework.try(:user).try(:realname) == ' '%>
|
||||
<%= link_to(homework.try(:user), user_path(homework.user_id)) %>
|
||||
<% else %>
|
||||
<%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=StudentWork.where('homework_common_id=?',homework.id).count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_date(homework.end_time) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_user_homework)) -%>
|
|
@ -0,0 +1,73 @@
|
|||
<h3>
|
||||
<%=l(:label_latest_login_user_list)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
登录时间
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
用户id
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
用户姓名
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
用户昵称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
用户身份
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0 %>
|
||||
<% for user in @user do %>
|
||||
<tr>
|
||||
<% @count +=1 %>
|
||||
<td align="center">
|
||||
<%=@count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_date(user.last_login_on) %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=user.id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if user.try(:realname) == ' '%><%= user.login%><% else %><%=user.try(:realname) %><% end %>'>
|
||||
<% if user.try(:realname) == ' '%>
|
||||
<%= link_to(user.login, user_path(user)) %>
|
||||
<% else %>
|
||||
<%= link_to(user.try(:realname), user_path(user)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=link_to(user.login, user_path(user)) %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<% case user.user_extensions.identity %>
|
||||
<% when 0 %>
|
||||
<%='老师' %>
|
||||
<% when 1 %>
|
||||
<%='学生' %>
|
||||
<% when 2 %>
|
||||
<%='企业' %>
|
||||
<% when 3 %>
|
||||
<%='开发者' %>
|
||||
<% else %>
|
||||
<%='未知身份' %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_latest_login_user_list)) -%>
|
|
@ -0,0 +1,79 @@
|
|||
<h3>
|
||||
<%=l(:label_leave_message_list)%>
|
||||
</h3>
|
||||
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
类型
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
留言人
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
留言时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
留言内容
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for journal in @jour -%>
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%case journal.jour_type %>
|
||||
<% when 'Principal' %>
|
||||
<%='用户主页' %>
|
||||
<% when 'Course' %>
|
||||
<%='课程' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= journal.jour_id %>
|
||||
</td>
|
||||
<td align="center" title='<%= journal.try(:user).try(:realname)%>'>
|
||||
<%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(journal.created_on) %>
|
||||
</td>
|
||||
<td title='<%=journal.notes %>'>
|
||||
<%= journal.notes.truncate(15, omission: '...') %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<% if(journal.m_reply_count) %>
|
||||
<%=journal.m_reply_count%>
|
||||
<% else %>
|
||||
<%=0 %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @jour_pages, @jour_count %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_leave_message_list)) -%>
|
|
@ -0,0 +1,69 @@
|
|||
<h3>
|
||||
<%=l(:label_message_plural)%>
|
||||
</h3>
|
||||
|
||||
<%= render 'tab_messages' %>
|
||||
<h4><%=l(:label_forum) %></h4>
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for memo in @memo -%>
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= memo.forum_id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if memo.try(:author).try(:realname) == ' '%><%= memo.try(:author)%><% else %><%=memo.try(:author).try(:realname) %><% end %>'>
|
||||
<% if memo.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(memo.try(:author), user_path(memo.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(memo.try(:author).try(:realname), user_path(memo.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(memo.created_at) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=memo.subject %>'>
|
||||
<%= memo.subject %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=memo.replies_count %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--<div class="pagination">
|
||||
<ul>
|
||||
<#%= pagination_links_full @memo_pages, @memo_count %>
|
||||
</ul>
|
||||
</div>-->
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
|
@ -0,0 +1,74 @@
|
|||
<h3>
|
||||
<%=l(:label_notification_list)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
课程id
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
课程名称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
主讲老师
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for news in @news -%>
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=news.course_id %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title="<%=news.course.name %>">
|
||||
<%=link_to(news.course.name, course_path(news.course)) %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title="<%=news.course.try(:teacher).try(:realname) %>">
|
||||
<%=link_to(news.course.try(:teacher).try(:realname), user_path(news.course.teacher)) %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if news.try(:author).try(:realname) == ' '%><%= news.try(:author)%><% else %><%=news.try(:author).try(:realname) %><% end %>'>
|
||||
<% if news.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(news.try(:author), user_path(news.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(news.try(:author).try(:realname), user_path(news.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(news.created_on) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=news.title %>'>
|
||||
<%= link_to(news.title, news_path(news)) %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=news.comments_count %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_notification_list)) -%>
|
|
@ -0,0 +1,66 @@
|
|||
<h3>
|
||||
<%=l(:label_message_plural)%>
|
||||
</h3>
|
||||
|
||||
<%= render 'tab_messages' %>
|
||||
<h4><%=l(:label_borad_project) %></h4>
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
来源
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
时间
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
标题
|
||||
</th>
|
||||
<th style="width: 30px;">
|
||||
回复数
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @count=0%>
|
||||
<% for project in @project_ms -%>
|
||||
|
||||
<% @count=@count + 1 %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center;">
|
||||
<%= @count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= Board.where('id=?',project.board_id).first.project_id %>
|
||||
</td>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if project.try(:author).try(:realname) == ' '%><%= project.try(:author)%><% else %><%=project.try(:author).try(:realname) %><% end %>'>
|
||||
<% if project.try(:author).try(:realname) == ' '%>
|
||||
<%= link_to(project.try(:author), user_path(project.author)) %>
|
||||
<% else %>
|
||||
<%= link_to(project.try(:author).try(:realname), user_path(project.author)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(project.created_on) %>
|
||||
</td>
|
||||
<td title='<%=project.subject %>' style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name">
|
||||
<%= project.subject %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%=project.replies_count %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
|
@ -0,0 +1,50 @@
|
|||
<h3 style="float: left">
|
||||
<%=l(:label_school_plural)%>
|
||||
</h3>
|
||||
<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>
|
||||
<%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>
|
||||
<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>">
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="autoscroll" style="margin-top: 40px;">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
LOGO
|
||||
</th>
|
||||
<th>
|
||||
学校名称
|
||||
</th>
|
||||
<th style="width: 100px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @schools.each do |school|%>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align:center;vertical-align: middle;">
|
||||
<%= school.id %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%= image_tag(school.logo_link,width:40,height:40) %>
|
||||
</td>
|
||||
<td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=school.name%>'>
|
||||
<span>
|
||||
<%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="buttons" style="vertical-align: middle;">
|
||||
<%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
|
||||
<%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_project_plural)) -%>
|
|
@ -17,6 +17,8 @@ if (window.Messenger) {
|
|||
Messenger().post({
|
||||
id: "label_apply_project_waiting",
|
||||
message: "<%= l(:label_apply_project_waiting) %>",
|
||||
showCloseButton: true,
|
||||
showCloseButton: true
|
||||
});
|
||||
};
|
||||
|
||||
$("#applied_project_link_<%= @project.id%>").replaceWith("<%= escape_javascript(link_to "加入项目",appliedproject_path(:user_id => User.current.id,:project_id => @project.id,:project_join => true),:class => "blue_n_btn fr mt20", :remote => "true",:method => "post",:id => "applied_project_link_#{@project.id}") %>");
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<% elsif @status == 2%>
|
||||
alert("<%= l('project.join.tips.success') %>");
|
||||
hideModal($("#popbox"));
|
||||
$("#applied_project_link_<%= @project.id%>").replaceWith("<%=escape_javascript(link_to '取消申请',appliedproject_applied_path(:project_id => @project.id,:user_id => User.current.id),:class => "blue_n_btn fr mt20", :remote => "true",:method => "delete",:id => "applied_project_link_#{@project.id}")%>");
|
||||
<% elsif @status == 3%>
|
||||
alert("<%= l('project.join.tips.has') %>");
|
||||
<%else%>
|
||||
|
|
|
@ -29,32 +29,32 @@
|
|||
<% is_float ||= false %>
|
||||
<% for attachment in attachments %>
|
||||
<div style="float:left;">
|
||||
<p style="height:14px;line-height:12px;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%if is_float%>
|
||||
<div style="max-width:55%;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;float: left;">
|
||||
<% end%>
|
||||
<span title="<%= attachment.filename %>" id = "attachment_">
|
||||
<p style="height:14px;line-height:12px;width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%if is_float%>
|
||||
<div style="max-width:55%;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;float: left;">
|
||||
<% end%>
|
||||
<span title="<%= attachment.filename %>" id = "attachment_">
|
||||
<% if options[:length] %>
|
||||
<%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%>
|
||||
<% else %>
|
||||
<%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%>
|
||||
<% end %>
|
||||
</span>
|
||||
<%if is_float%>
|
||||
</div>
|
||||
<% end%>
|
||||
<%if is_float%>
|
||||
</div>
|
||||
<% end%>
|
||||
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments',
|
||||
:action => 'show',
|
||||
:id => attachment,
|
||||
:filename => attachment.filename%>
|
||||
<% end %>
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments',
|
||||
:action => 'show',
|
||||
:id => attachment,
|
||||
:filename => attachment.filename%>
|
||||
<% end %>
|
||||
</div>
|
||||
<div style="float:left;max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="<%= attachment.description%>">
|
||||
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||
</div>
|
||||
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||
</div>
|
||||
<span class="size">(
|
||||
<%= number_to_human_size attachment.filesize %>)
|
||||
</span>
|
||||
|
@ -66,6 +66,16 @@
|
|||
:class => 'delete delete-homework-icon',
|
||||
:remote => true,
|
||||
:title => l(:button_delete) %>
|
||||
<% elsif attachment.container_type == 'Issue' %>
|
||||
<% if User.current == attachment.author %>
|
||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:method => :delete,
|
||||
:class => 'delete',
|
||||
#:remote => true,
|
||||
#:id => "attachments_" + attachment.id.to_s,
|
||||
:title => l(:button_delete) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
|
@ -89,13 +99,13 @@
|
|||
</p>
|
||||
<% end %>
|
||||
<div class="thumbnails">
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = attachments.select(&:thumbnailable?) %>
|
||||
<% if images.any? %>
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = attachments.select(&:thumbnailable?) %>
|
||||
<% if images.any? %>
|
||||
<% images.each do |attachment| %>
|
||||
<div class="pro_pic fl " width="100" height="73"><%= thumbnail_issue_tag(attachment) %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
|
||||
</div>
|
||||
</span>
|
||||
<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
|
||||
<%= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
|
||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||
<span><%= l(:button_upload_photo) %></span>
|
||||
</a>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<% if @source_type=='User' %>
|
||||
var imgSpan = $("img[nhname='avatar_image']");
|
||||
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
|
||||
<% else %>
|
||||
var imgSpan = jQuery('#avatar_image');
|
||||
|
||||
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
|
||||
|
||||
<% end %>
|
|
@ -1,7 +1,7 @@
|
|||
<%= error_messages_for @board %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p style="width:666;">
|
||||
<p style="width:666px;">
|
||||
<%= f.text_field :name, :required => true %>
|
||||
</p><!--by young-->
|
||||
<p>
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<style type="text/css">
|
||||
div.talk_new .ke-container{margin-left:2px;}
|
||||
/*div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
|
||||
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
|
||||
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
|
||||
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
|
||||
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
|
||||
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
|
||||
div.ke-toolbar .ke-outline{border:none;}*/
|
||||
.break_word {width:100%;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
|
@ -16,14 +9,14 @@
|
|||
for (var i=0; i<menuids.length; i++){
|
||||
var div = document.getElementById(menuids[i]);
|
||||
if(div == undefined)continue;
|
||||
var ultags=div.getElementsByTagName("ul")
|
||||
var ultags=div.getElementsByTagName("ul");
|
||||
for (var t=0; t<ultags.length; t++){
|
||||
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
|
||||
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle";
|
||||
ultags[t].parentNode.onmouseover=function(){
|
||||
this.getElementsByTagName("ul")[0].style.display="block"
|
||||
this.getElementsByTagName("ul")[0].style.display="block";
|
||||
}
|
||||
ultags[t].parentNode.onmouseout=function(){
|
||||
this.getElementsByTagName("ul")[0].style.display="none"
|
||||
this.getElementsByTagName("ul")[0].style.display="none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,46 +39,6 @@
|
|||
|
||||
<script type="text/javascript">//侧导航
|
||||
|
||||
//window.onload = function () {
|
||||
// var topic_id = getParam('topic_id');
|
||||
// document.getElementById(topic_id).focus();
|
||||
//}
|
||||
//
|
||||
//var getParam = function(name){
|
||||
// var search = document.location.search;
|
||||
// var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
|
||||
// var matcher = pattern.exec(search);
|
||||
// var items = null;
|
||||
// if(null != matcher){
|
||||
// try{
|
||||
// items = decodeURIComponent(decodeURIComponent(matcher[1]));
|
||||
// }catch(e){
|
||||
// try{
|
||||
// items = decodeURIComponent(matcher[1]);
|
||||
// }catch(e){
|
||||
// items = matcher[1];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return items;
|
||||
//};
|
||||
//
|
||||
//function show_newtalk()
|
||||
//{
|
||||
// $("#about_newtalk").toggle();
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
||||
//function show_newtalk1(id)
|
||||
//{
|
||||
// $(id).toggle();
|
||||
// $(id).focus();
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
if(params.subject!=undefined){
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
|
||||
<!--gcm-->
|
||||
<p class="stats">
|
||||
<%= content_tag('span', link_to("#{@course_activity_count[@course.id]}", course_path(@course)), :class => "info") %>
|
||||
<%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>
|
||||
<%= content_tag('span', link_to("#{@course.course_activities.count}", course_path(@course)), :class => "info") %>
|
||||
<%= content_tag('span', l(:label_x_activity, :count => @course.course_activities.count)) %>
|
||||
</p>
|
||||
<!--gcm-->
|
||||
|
||||
|
|
|
@ -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();$('#new_group_name').hide();">
|
||||
<a href="javascript:void(0)" class="f_l" style="padding-left: 5px;" onclick="$('#group_name_<%= group.id %>').val('<%= group.name%>');$('#edit_group_<%= group.id %>').slideToggle();$('#new_group_name').hide();">
|
||||
<img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" />
|
||||
</a>
|
||||
<% end %>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<% if @canShowCode%>
|
||||
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, :id => 'update_group_'+group.id.to_s) do %>
|
||||
<span id="edit_group_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
|
||||
<input type="text" id="group_name_<%= group.id%>" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
|
||||
<input type="text" id="group_name_<%= group.id%>" name="group_name" size="20" class="isTxt w90 f_l" maxlength="20" />
|
||||
<input type="button" class="submit f_l" onclick="edit_group('group_name_<%= group.id%>','<%= valid_ajax_course_path%>','<%= @course.id%>','<%= group.id%>');"/>
|
||||
</span>
|
||||
<% end %>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<li >
|
||||
<span id="new_group_name" style="display:none; vertical-align: middle;" class="ml10 f_l">
|
||||
<%= form_tag( addgroups_course_path(@course), method: 'get',:remote=>true,:id => 'add_group_name') do %>
|
||||
<input type="text" id="group_name" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
|
||||
<input type="text" id="group_name" name="group_name" size="20" class="isTxt w90 f_l" maxlength="20" />
|
||||
<input type="button" class="submit f_l" onclick="add_group('<%= valid_ajax_course_path%>','<%= @course.id%>');"/>
|
||||
<% end %>
|
||||
</span>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
:member_id => member.id,
|
||||
:remote => true},
|
||||
:class => 'ml258 c_red' %>
|
||||
<span class="ml65 c_grey"><%= format_date(member.created_on)%></span>
|
||||
<span class="fr mr15 c_grey"><%= format_date(member.created_on)%></span>
|
||||
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
<% if @state %>
|
||||
<% if @state == 0 %>
|
||||
alert("加入成功");
|
||||
hideModal($("#popbox"));
|
||||
hideModal($("#popbox02"));
|
||||
$("#try_join_course_link").replaceWith("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
<% elsif @state == 1 %>
|
||||
alert("密码错误");
|
||||
<% elsif @state == 2 %>
|
||||
alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)");
|
||||
<% elsif @state == 3 %>
|
||||
alert("您已经加入了课程");
|
||||
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
|
||||
<% elsif @state == 4 %>
|
||||
alert("您加入的课程不存在");
|
||||
<% elsif @state == 5 %>
|
||||
|
|
|
@ -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', '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");
|
||||
|
|
|
@ -39,17 +39,17 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if @courses.size == 0 %>
|
||||
<%= render :partial => 'layouts/no_content'%>
|
||||
<% if @courses && !@courses.empty? %>
|
||||
<div id="courses-index">
|
||||
<%= render_course_hierarchy(@courses)%>
|
||||
</div>
|
||||
<% else %>
|
||||
<div id="courses-index">
|
||||
<%= render_course_hierarchy(@courses)%>
|
||||
</div>
|
||||
<%= render :partial => 'layouts/no_content'%>
|
||||
<% end %>
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @course_pages %>
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,83 +1,37 @@
|
|||
<div class="project_r_h">
|
||||
<% if @controller_name=='ActivityNotifys' %>
|
||||
<a class="fl about_me" style="width:80px;" href="<%=course_path(@course)%>"><%= l(:label_activity)%></a>
|
||||
<h2 class="fl project_h2" style="width:100px;">与我相关
|
||||
<span class="c_orange f12" style="display:none;">(<font id="new_notify_count"><%=get_new_notify_count(@course,'Course')%></font>)</span>
|
||||
</h2>
|
||||
<div class="fr mt10 mr5 c_grey02">
|
||||
<a class="c_dblue">
|
||||
<label class="mr5" style="cursor:pointer;" data-href="<%= course_activity_notifys_path(@course) %>/chang_read_flag" nhname='nh_act_link_all'>全部标为已读</label>
|
||||
</a>
|
||||
</div>
|
||||
<% else %>
|
||||
<h2 class="fl project_h2"><%= l(:label_activity)%></h2>
|
||||
<% if User.current.logged? %>
|
||||
<a class="fl about_me" href="<%=course_activity_notifys_path(@course)%>">与我相关
|
||||
<span class="c_orange f12" style="display:none;">(<font id="new_notify_count"><%=get_new_notify_count(@course,'Course')%></font>)</span>
|
||||
</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if @events_by_day != nil && @events_by_day.size >0 %>
|
||||
<% @events_by_day.keys.sort.reverse.each do |day| %>
|
||||
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
|
||||
<div class="problem_main" nhname="container">
|
||||
<a class="problem_pic fl">
|
||||
<%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %>
|
||||
</a>
|
||||
<div class="problem_txt fl mt5 upload_img">
|
||||
<%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %>
|
||||
<%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %>
|
||||
<span class="fl"> </span>
|
||||
<span class="fl"> <%= l(:label_new_activity) %>:</span>
|
||||
<%
|
||||
link = (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) :
|
||||
(e.event_type.eql?("bid") ? homework_course_path(@course) :
|
||||
(e.event_type.eql?("message") || e.event_type.eql?("reply") ?
|
||||
course_boards_path(@course,:topic_id => e.id,:parent_id=>(e.parent_id ? e.parent_id : e.id)) : e.event_url))
|
||||
%>
|
||||
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
|
||||
:class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
|
||||
'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
|
||||
'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
|
||||
<%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
|
||||
<span nhname="nh_act_flag" class="ml10 fl"><img src="/images/new.png" width="35" height="15"/></span>
|
||||
<%end%>
|
||||
<br />
|
||||
<p class="mt5 break_word"><%= e.event_description.html_safe %>
|
||||
<br />
|
||||
<div class="cl"></div>
|
||||
<%= l :label_activity_time %> : <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %>
|
||||
</p>
|
||||
<%= link_to_attachments_course(e) if e.class.to_s == "News" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--课程动态 end-->
|
||||
<% end%>
|
||||
<% end%>
|
||||
<% elsif @controller_name=='ActivityNotifys' %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end%>
|
||||
<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
|
||||
<div class="problem_main">
|
||||
<a class="problem_pic fl">
|
||||
<%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %>
|
||||
</a>
|
||||
<div class="problem_txt fl mt5">
|
||||
<%= link_to_user_header(@user,false,:class => 'problem_name c_orange fl') %>
|
||||
<%= link_to_user_header("(#{@user})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName %>
|
||||
<span class="fl"> <%= l(:label_user_create_project) %>:</span>
|
||||
<%= link_to @course.name,course_path(@course),:class => "problem_tit c_dblue fl fb"%>
|
||||
<br />
|
||||
<p class="mt5">
|
||||
<br />
|
||||
<%= l :label_create_time %> : <%= format_time(@course.created_at) %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--课程动态 end-->
|
||||
<%@course_activities.each do |activity|%>
|
||||
<div class="problem_main" nhname="container">
|
||||
<a class="problem_pic fl">
|
||||
<%= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %>
|
||||
</a>
|
||||
<div class="problem_txt fl mt5 upload_img">
|
||||
<%= link_to_user_header(activity.user,false,:class => 'problem_name c_orange fl') %>
|
||||
<span class="fl"> </span>
|
||||
<span class="fl"> <%= activity.course_act_type == "Course" ? "创建了课程" : l(:label_new_activity) %>:</span>
|
||||
<%#= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
|
||||
:class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
|
||||
'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
|
||||
'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
|
||||
<%#if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
|
||||
<!--span nhname="nh_act_flag" class="ml10 fl"><img src="/images/new.png" width="35" height="15"/></span-->
|
||||
<%#end%>
|
||||
<%= link_to course_activity_link activity%>
|
||||
<div class="cl"></div>
|
||||
<p class="mt5 break_word">
|
||||
<%= course_activity_desc activity%>
|
||||
<br />
|
||||
<div class="cl"></div>
|
||||
<%= activity.course_act_type == "Course" ? l(:label_create_time) : l(:label_activity_time) %> : <%= format_time(activity.created_at) %>
|
||||
</p>
|
||||
<%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!--课程动态 end-->
|
||||
<% end%>
|
||||
|
||||
<ul class="wlist">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
</ul>
|
||||
|
|
|
@ -24,6 +24,8 @@ $('#upload_file_div').slideToggle('slow');
|
|||
<% if @project %>
|
||||
closeModal();
|
||||
$("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>');
|
||||
$("#project_files_count_info").html("<%= @all_attachments.count%>");
|
||||
$("#project_files_count_nav").html("(<%= @all_attachments.count%>)")
|
||||
// 添加文件上传成功提示
|
||||
<% unless params[:attachments].nil? %>
|
||||
var div = $('<div id="addBox" class="flash notice">文件上传成功!</div>');
|
||||
|
|
|
@ -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,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>
|
||||
|
|
|
@ -48,11 +48,12 @@
|
|||
<ul class="ml10">
|
||||
<li>
|
||||
<label class="label02">迟交扣分: </label>
|
||||
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<input type="number" value="<%= homework.late_penalty%>" min="0" max="50" class="fl mb10 h26 w70" name="late_penalty" onkeyup="check_late_penalty()">
|
||||
<span class="fl mt5"> 分</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<li style="display: none;">
|
||||
<label class="label02" >是否匿评: </label>
|
||||
<%= f.check_box :homework_type, :class => "mb10 mt5 fl" %>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
|
||||
<li>
|
||||
<label class="label02">迟交扣分: </label>
|
||||
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
|
||||
<input type="number" value="<%= homework.late_penalty%>" min="0" max="50" class="fl mb10 h26 w70" name="late_penalty" onkeyup="check_late_penalty()">
|
||||
<span class="fl mt5"> 分</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
@ -56,9 +57,7 @@
|
|||
<ul>
|
||||
<li >
|
||||
<label class="label02"> 开发语言: </label>
|
||||
<select class="fl mb10 h26 w150" >
|
||||
<option>C++</option>
|
||||
</select>
|
||||
<%= select_tag :language,options_for_select(programing_languages_options,homework.homework_detail_programing.language.to_i), {:class => "fl mb10 h26 w70",:onchange => "homework_language_change($(this));"} %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
|
@ -80,7 +79,7 @@
|
|||
|
||||
<li >
|
||||
<label class="label02"> 标准代码: </label>
|
||||
<textarea name="standard_code" class=" w547 h150 mb10 fl"><%= homework.homework_detail_programing.standard_code%></textarea>
|
||||
<textarea name="standard_code" class=" w547 h400 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code || c_stantard_code_teacher%></textarea>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
|
@ -89,16 +88,25 @@
|
|||
<div>
|
||||
<li>
|
||||
<label class="label02"> 测试输入: </label>
|
||||
<input type="text" class="fl h26 w186 mb10" name="input[<%= homework_test.id%>]" value="<%= homework_test.input%>"/>
|
||||
<input type="text" class="fl h26 w190 mb10" name="input[<%= homework_test.id%>]" value="<%= homework_test.input%>"/>
|
||||
</li>
|
||||
<li >
|
||||
<label class=" fl f14 ml10"> 输出: </label>
|
||||
<input type="text" class="fl h26 w186 mb10" name="output[<%= homework_test.id%>]" value="<%= homework_test.output%>"/>
|
||||
<input type="text" class="fl h26 w190 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>
|
||||
<% if homework_test.result && !homework_test.result.to_s.empty?%>
|
||||
<% if homework_test.result == 0%>
|
||||
<a class="green_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">正确</a>
|
||||
<% else%>
|
||||
<a class="red_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">错误</a>
|
||||
<% end%>
|
||||
<% else%>
|
||||
<a class="blue_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">测试</a>
|
||||
<% end%>
|
||||
<input type="hidden" id="test_result_<%= homework_test.id%>" name="result[<%= homework_test.id%>]" value="<%= homework_test.result%>"/>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -107,19 +115,79 @@
|
|||
<div>
|
||||
<li>
|
||||
<label class="label02"> 测试输入: </label>
|
||||
<input type="text" class="fl h26 w186 mb10" name="input[0]" />
|
||||
<input type="text" class="fl h26 w190 mb10" name="input[0]" value="1 2"/>
|
||||
</li>
|
||||
<li >
|
||||
<label class=" fl f14 ml10"> 输出: </label>
|
||||
<input type="text" class="fl h26 w186 mb10" name="output[0]" />
|
||||
<input type="text" class="fl h26 w190 mb10" name="output[0]" value="3"/>
|
||||
</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>
|
||||
<a class="blue_btn fl ml5 mt programing_test" onclick="programing_test('0')" id="test_send_0">测试</a>
|
||||
<input type="hidden" id="test_result_0" name="result[0]" />
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<input type="hidden" name="error_msg" id="homework_test_error_msg" value="<%= homework.homework_tests.first.error_msg if homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg%>">
|
||||
<table class="border_ce" cellpadding="0" cellspacing="0" id="homework_work_test_show" style="display: <%= homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg && !homework.homework_tests.first.error_msg.empty? ? "block" : "none"%>">
|
||||
<tbody>
|
||||
<tr class="border_t" >
|
||||
<td class="td_end fb c_red w60 td_board_left">
|
||||
错误信息:
|
||||
</td>
|
||||
<td class="td_end wl" id="homework_work_test_desc">
|
||||
<% if homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg %>
|
||||
<%= homework.homework_tests.first.error_msg%>
|
||||
<% end%>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
//点击测试,发送
|
||||
function programing_test(obj) {
|
||||
$.post(
|
||||
'<%= programing_test_homework_common_index_path%>',
|
||||
{
|
||||
src: $("textarea[name='standard_code']").val(),
|
||||
input: $("input[name='input[" + obj +"]']").val(),
|
||||
output: $("input[name='output[" + obj + "]']").val(),
|
||||
language: $("select[name='language']").val(),
|
||||
index: obj
|
||||
},
|
||||
function (data) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function init_programing_test()
|
||||
{
|
||||
$(".programing_test").each(function(){
|
||||
$(this).removeClass("green_btn red_btn").addClass("blue_btn").text("测试");
|
||||
$(this).next("input").val("");
|
||||
});
|
||||
}
|
||||
|
||||
function homework_language_change(obj)
|
||||
{
|
||||
if(obj.val() == "1")
|
||||
{
|
||||
// alert(1);
|
||||
$("textarea[name='standard_code']").val("<%= escape_javascript c_stantard_code_teacher%>");
|
||||
|
||||
}
|
||||
else if(obj.val() == "2")
|
||||
{
|
||||
// alert(2);
|
||||
$("textarea[name='standard_code']").val("<%= escape_javascript c_stantard_code_teacher_%>");
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -48,15 +48,55 @@
|
|||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt5">
|
||||
<% unless homework.attachments.empty?%>
|
||||
<% if homework.homework_type == 2 && homework.homework_detail_programing%>
|
||||
<% if @is_teacher%>
|
||||
<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>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
<div class="mt5">
|
||||
<span class="tit_fb" style="width: auto;"> 开发语言:</span>
|
||||
<div class="fl">
|
||||
<% if homework.homework_detail_programing.language.to_i == 1%>
|
||||
C
|
||||
<% elsif homework.homework_detail_programing.language.to_i == 2%>
|
||||
C++
|
||||
<% end%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
<% unless homework.attachments.empty?%>
|
||||
<div class="mt5">
|
||||
<span class="tit_fb" style="width: auto;"> 附件:</span>
|
||||
<div class="fl mb5">
|
||||
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework.attachments} %>
|
||||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
|
||||
<div class="mt5">
|
||||
<span class="tit_fb" style="width: auto;"> 扣分标准:</span>
|
||||
|
|
|
@ -1,27 +1,17 @@
|
|||
<%= 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>
|
||||
<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++程序的自动评分)
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class=" orange_btn" onclick="$(this).parent().submit();">
|
||||
下一步
|
||||
</a>
|
||||
<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-->
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<%= 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 "上一步", 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-->
|
||||
|
@ -22,7 +22,7 @@
|
|||
<%= 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 "上一步", 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-->
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
|
||||
$("#test_result_<%= @index%>").val("<%= @result%>");
|
||||
<% if @err_msg || @result != 0%>
|
||||
$("#homework_work_test_show").show();
|
||||
$("#homework_work_test_desc").text("<%= escape_javascript(@err_msg || status_to_err_msg(@result))%>");
|
||||
<% if @err_msg%>
|
||||
$("#homework_test_error_msg").val("<%= escape_javascript(@err_msg)%>");
|
||||
<% end%>
|
||||
<% else%>
|
||||
$("#homework_work_test_show").hide();
|
||||
$("#homework_test_error_msg").val("");
|
||||
<% end%>
|
|
@ -6,7 +6,7 @@
|
|||
<div class="pro_page_box">
|
||||
<div class="pro_page_top break_word">
|
||||
<%= link_to "#{@issue.project.name}"+">", project_issues_path(@issue.project) %>
|
||||
<a href="javascript:void(0)"><%= "#" + @issue.project_index %></a>
|
||||
<a href="javascript:void(0)"><%= "#" + @issue.id.to_s %></a>
|
||||
</div>
|
||||
<div class="problem_main">
|
||||
<div class="ping_dispic">
|
||||
|
|
|
@ -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>
|
|
@ -0,0 +1,46 @@
|
|||
<div id="Footer">
|
||||
<div class="footerAboutContainer">
|
||||
<ul class="footerAbout">
|
||||
<li class="fl"><a href="javascript:void:(0);" class="f_grey mw20" target="_blank"><%= l(:label_about_us)%></a>|</li>
|
||||
<li class="fl"><a href="http://forge.trustie.net/projects/2/feedback" class="f_grey mw20" target="_blank"><%= l(:label_contact_us)%></a>|</li>
|
||||
<li class="fl"><a href="javascript:void:(0);" class="f_grey mw20" target="_blank"><%= l(:label_recruitment_information)%></a>|</li>
|
||||
<li class="fl"><a href="http://forge.trustie.net/forums/1/memos/1168" class="f_grey mw20" target="_blank"><%= l(:label_surpport_group)%></a>|</li>
|
||||
<li class="fl"><a href="javascript:void:(0);" class="f_grey mw20" target="_blank"><%= l(:label_forums)%></a>|</li>
|
||||
<li class="fl"><a href="javascript:void:(0);" class="f_grey ml20" target="_blank"><%= l(:label_language)%></a>
|
||||
<select class="languageBox">
|
||||
<option value="Chinese" selected="selected">中文</option>
|
||||
<option value="English">英文</option>
|
||||
</select>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="cl"></div>
|
||||
<ul class="departments">
|
||||
<li class="fl mr10">
|
||||
<strong><%= l(:label_hosted_organization)%></strong><a href="http://www.nudt.edu.cn/ArticleShow.asp?ID=47" class=" ml10 f_grey" target="_blank"><%= l(:label_hosted_by)%></a>
|
||||
</li>
|
||||
<li class="fl">
|
||||
<a href="http://www.nudt.edu.cn/ArticleShow.asp?ID=41" class="mr45 f_grey" target="_blank"><%= l(:label_sponsor)%></a>
|
||||
</li>
|
||||
<li class="fl mr10">
|
||||
<strong><%= l(:label_partners)%></strong><a href="http://eecs.pku.edu.cn" class="ml10 f_grey" target="_blank"><%= l(:label_co_organizer_EECS)%></a>
|
||||
</li>
|
||||
<li class="fl">
|
||||
<a href="http://scse.buaa.edu.cn/" class="mr10 f_grey" target="_blank"><%= l(:label_co_organizer_BHU)%></a>
|
||||
</li>
|
||||
<li class="fl">
|
||||
<a href="http://www.iscas.ac.cn/" class="mr10 f_grey" target="_blank"><%= l(:label_co_organizer_CAS)%></a>
|
||||
</li>
|
||||
<li class="fl">
|
||||
<a href="http://www.inforbus.com/" class="f_grey" target="_blank"><%= l(:label_co_organizer_InforS)%></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<ul class="copyright">
|
||||
<li class="fl"><%= l(:label_rights_reserved)%></li>
|
||||
<span class="fl mw15">|</span>
|
||||
<li class="fl"><a href="http://www.miibeian.gov.cn/" class="fl f_grey" target="_blank"><%= l(:label_license)%></a></li>
|
||||
</ul>
|
||||
</div><!--Footer end-->
|
||||
<div class="cl"></div>
|
|
@ -18,7 +18,7 @@
|
|||
<ul class="sub_menu">
|
||||
<% if @show_course == 1 && !visiable %>
|
||||
<% hasCourse=false %>
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% User.current.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<% hasCourse=true %>
|
||||
<% break %>
|
||||
|
@ -34,9 +34,10 @@
|
|||
</li>
|
||||
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;">
|
||||
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')',
|
||||
{ :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user },
|
||||
{:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user},
|
||||
{:class => 'my-message'} if User.current.logged?%>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<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.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<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.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").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>
|
||||
</ul>
|
||||
</li><!---level1 end--->
|
||||
<!--消息提醒-->
|
||||
<div class="navHomepageNews">
|
||||
<%= link_to image_tag("/images/news_icon_small.png" , :width => "21", :height => "24"), {:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
|
||||
<% if User.current.count_new_message >0 %>
|
||||
<div class="newsActive"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!--消息提醒end-->
|
||||
<!--<li ><a href="javascript:void(0);">退出</a></li>-->
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= render_menu :account_menu -%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -26,7 +26,7 @@
|
|||
<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.reverse.each do |course| %>
|
||||
<% user_course.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.reverse.each do |project| %>
|
||||
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").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>
|
||||
|
@ -53,6 +53,9 @@
|
|||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<% end -%>
|
||||
<%= header_render_menu :account_menu -%>
|
||||
</ul>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ul class="course_sub_menu">
|
||||
<% course_index = 0 %>
|
||||
|
||||
<% User.current.courses.reverse.each do |course| %>
|
||||
<% User.current.courses.each do |course| %>
|
||||
<% if !course_endTime_timeout?(course) %>
|
||||
<%= render :partial => 'layouts/user_homework_list', :locals => {:course => course,:course_index => course_index} %>
|
||||
<% course_index += 1 %>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<% fans_count,fans_list = get_fans_users(user) %>
|
||||
<div id="fans_nav_list" class="leftbox mt10" style="display:<%= fans_count==0 ? 'none' : 'block' %>">
|
||||
<h4 class="fl">粉丝</h4><a href="<%=url_for(:controller => 'users', :action => 'user_fanslist', :id=>user.id)%>" data-count="<%= fans_count %>" style="display:<%= fans_count>10 ? 'block' : 'block' %>" class="more fr mr10">更多</a>
|
||||
<div class="cl"></div>
|
||||
<div class="mt5">
|
||||
<% for fans in fans_list %>
|
||||
<%= link_to image_tag(url_to_avatar(fans), :style => "width:38px;height:38px;"), user_path(fans), :class => "pic_members", :title => "#{fans.name}" %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!--leftbox end-->
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
|
||||
<ul class="project_sub_menu" style="top:<%= hasCourse ? 35 : 0 %>px;">
|
||||
<% User.current.projects.reverse.each do |project| %>
|
||||
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
|
||||
<li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=project.name%>">
|
||||
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
|
||||
</li>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<% if User.current.logged?%>
|
||||
<% if User.current == target%>
|
||||
<a href="<%= url_for(:controller => 'my', :action => 'account') %>" class="fr gz_btn mr10 ">编辑资料</a>
|
||||
<%else%>
|
||||
<%if(target.watched_by?(User.current))%>
|
||||
<a id="user_watch_id" href="<%= watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id) %>" class="fr qx_btn mr10" data-method="delete" data-remote="true" title="取消关注">取消关注</a>
|
||||
<% else %>
|
||||
<a id="user_watch_id" href="<%= watch_path(:object_type=>'user',:object_id=>target.id,:target_id=>target.id) %>" class="fr gz_btn mr10" data-method="post" data-remote="true" title="添加关注">添加关注</a>
|
||||
<% end %>
|
||||
<% end%>
|
||||
<% end %>
|
|
@ -0,0 +1,11 @@
|
|||
<% watcher_count,watcher_list = get_watcher_users(user) %>
|
||||
<div id="watcher_nav_list" class="leftbox" style="display:<%= watcher_count==0 ? 'none' : 'block' %>">
|
||||
<h4 class="fl">关注</h4><a href="<%=url_for(:controller => 'users', :action => 'user_watchlist', :id=>user.id)%>" data-count="<%= watcher_count %>" style="display:<%= watcher_count>10 ? 'block' : 'block' %>" class="more fr mr10">更多</a>
|
||||
<div class="cl"></div>
|
||||
<div class="mt5">
|
||||
<% for watcher in watcher_list %>
|
||||
<%= link_to image_tag(url_to_avatar(watcher), :style => "width:38px;height:38px;"), user_path(watcher), :class => "pic_members", :title => "#{watcher.name}" %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!--leftbox end-->
|
|
@ -113,7 +113,7 @@
|
|||
<div class="subNav">
|
||||
<%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %>
|
||||
<!--暂时不显示课程动态数,优化后在显示-->
|
||||
<%= link_to "(#{course_activity_count @course})", course_path(@course), :class => "subnav_num c_orange"%>
|
||||
<%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
|
||||
</div>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
|
||||
|
|
|
@ -80,11 +80,13 @@
|
|||
<div class="cl"></div>
|
||||
<div>
|
||||
<% if @project.project_type == 0 %>
|
||||
<span class="fb f14 "><%= l(:label_project_score)%> :</span>
|
||||
<%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
|
||||
:action => 'show_projects_score',
|
||||
:remote => true,
|
||||
:id => @project.id}, :class => "c_orange f14" ) %>
|
||||
<% unless project_scores(@project) == 0 %>
|
||||
<span class="fb f14 "><%= l(:label_project_score)%> :</span>
|
||||
<%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
|
||||
:action => 'show_projects_score',
|
||||
:remote => true,
|
||||
:id => @project.id}, :class => "c_orange f14" ) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
@ -98,7 +100,7 @@
|
|||
<span>| </span>
|
||||
<%= l(:project_module_attachments) %>(
|
||||
<% attaments_num %>
|
||||
<%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue' %></span>)
|
||||
<%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %></span>)
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue