Merge branch 'szzh' into gitlab_guange
Conflicts: Gemfile app/models/user.rb db/schema.rb lib/trustie.rb 解决冲突
This commit is contained in:
commit
7c1bb8b9ed
4
Gemfile
4
Gemfile
|
@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
|
|||
gem 'iconv'
|
||||
end
|
||||
|
||||
gem 'grack', path:'./lib/grack'
|
||||
gem 'gitlab', path: 'lib/gitlab-cli'
|
||||
gem 'rest-client'
|
||||
gem "mysql2", "= 0.3.18"
|
||||
|
@ -42,6 +43,9 @@ group :development, :test do
|
|||
gem 'pry-byebug'
|
||||
end
|
||||
gem 'pry-stack_explorer'
|
||||
if RUBY_PLATFORM =~ /darwin/
|
||||
gem 'puma'
|
||||
end
|
||||
end
|
||||
|
||||
gem 'rspec-rails', '~> 3.0'
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the SystemMessages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -25,21 +25,33 @@ class AccountController < ApplicationController
|
|||
# Login request and validation
|
||||
def login
|
||||
if request.get?
|
||||
@login = params[:login] || true
|
||||
if User.current.logged?
|
||||
redirect_to home_url
|
||||
redirect_to user_path(User.current)
|
||||
else
|
||||
render :layout => 'login'
|
||||
end
|
||||
else
|
||||
authenticate_user
|
||||
end
|
||||
end
|
||||
|
||||
# 服务协议
|
||||
def agreement
|
||||
render :layout => 'static_base'
|
||||
end
|
||||
|
||||
def about_us
|
||||
render :layout => 'static_base'
|
||||
end
|
||||
|
||||
# Log out current user and redirect to welcome page
|
||||
def logout
|
||||
if User.current.anonymous?
|
||||
redirect_to home_url
|
||||
redirect_to signin_path
|
||||
elsif request.post?
|
||||
logout_user
|
||||
redirect_to home_url
|
||||
redirect_to signin_path
|
||||
end
|
||||
# display the logout form
|
||||
end
|
||||
|
@ -50,16 +62,16 @@ class AccountController < ApplicationController
|
|||
|
||||
# Lets user choose a new password
|
||||
def lost_password
|
||||
(redirect_to(home_url); return) unless Setting.lost_password?
|
||||
(redirect_to(signin_path); return) unless Setting.lost_password?
|
||||
if params[:token]
|
||||
@token = Token.find_token("recovery", params[:token].to_s)
|
||||
if @token.nil? || @token.expired?
|
||||
redirect_to home_url
|
||||
redirect_to signin_path
|
||||
return
|
||||
end
|
||||
@user = @token.user
|
||||
unless @user && @user.active?
|
||||
redirect_to home_url
|
||||
redirect_to signin_path
|
||||
return
|
||||
end
|
||||
if request.post?
|
||||
|
@ -71,7 +83,7 @@ class AccountController < ApplicationController
|
|||
return
|
||||
end
|
||||
end
|
||||
render :template => "account/password_recovery"
|
||||
render :template => "account/password_recovery"
|
||||
return
|
||||
else
|
||||
if request.post?
|
||||
|
@ -79,6 +91,7 @@ class AccountController < ApplicationController
|
|||
# user not found or not active
|
||||
unless user && user.active?
|
||||
flash.now[:error] = l(:notice_account_unknown_email)
|
||||
render :layout => 'static_base'
|
||||
return
|
||||
end
|
||||
# user cannot change its password
|
||||
|
@ -91,16 +104,17 @@ class AccountController < ApplicationController
|
|||
if token.save
|
||||
Mailer.run.lost_password(token)
|
||||
flash[:notice] = l(:notice_account_lost_email_sent)
|
||||
redirect_to signin_url
|
||||
redirect_to lost_password_path
|
||||
return
|
||||
end
|
||||
end
|
||||
render :layout => 'static_base'
|
||||
end
|
||||
end
|
||||
|
||||
# User self-registration
|
||||
def register
|
||||
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
|
||||
(redirect_to(signin_path); return) unless Setting.self_registration? || session[:auth_source_registration]
|
||||
if request.get?
|
||||
session[:auth_source_registration] = nil
|
||||
@user = User.new(:language => current_language.to_s)
|
||||
|
@ -128,10 +142,12 @@ class AccountController < ApplicationController
|
|||
end
|
||||
when '3'
|
||||
#register_automatically(@user)
|
||||
unless @user.new_record?
|
||||
if !@user.new_record?
|
||||
self.logged_user = @user
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
redirect_to my_account_url
|
||||
else
|
||||
redirect_to signin_path
|
||||
end
|
||||
else
|
||||
#register_manually_by_administrator(@user)
|
||||
|
@ -175,11 +191,11 @@ class AccountController < ApplicationController
|
|||
|
||||
# Token based account activation
|
||||
def activate
|
||||
(redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present?
|
||||
(redirect_to(signin_path); return) unless Setting.self_registration? && params[:token].present?
|
||||
token = Token.find_token('register', params[:token].to_s)
|
||||
(redirect_to(home_url); return) unless token and !token.expired?
|
||||
(redirect_to(signin_path); return) unless token and !token.expired?
|
||||
user = token.user
|
||||
(redirect_to(home_url); return) unless user.registered?
|
||||
(redirect_to(signin_path); return) unless user.registered?
|
||||
user.activate
|
||||
if user.save
|
||||
token.destroy
|
||||
|
@ -266,7 +282,7 @@ class AccountController < ApplicationController
|
|||
user = User.find_or_initialize_by_identity_url(identity_url)
|
||||
if user.new_record?
|
||||
# Self-registration off
|
||||
(redirect_to(home_url); return) unless Setting.self_registration?
|
||||
(redirect_to(signin_path); return) unless Setting.self_registration?
|
||||
|
||||
# Create on the fly
|
||||
user.login = registration['nickname'] unless registration['nickname'].nil?
|
||||
|
@ -353,12 +369,15 @@ class AccountController < ApplicationController
|
|||
|
||||
def invalid_credentials
|
||||
logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}"
|
||||
flash.now[:error] = l(:notice_account_invalid_creditentials)
|
||||
flash[:error] = l(:notice_account_invalid_creditentials)
|
||||
# render :layout => 'login'
|
||||
redirect_to signin_path(:login=>true)
|
||||
end
|
||||
|
||||
def invalid_credentials_new
|
||||
logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}"
|
||||
flash.now[:error] = l(:notice_account_invalid_creditentials_new)
|
||||
flash[:error] = l(:notice_account_invalid_creditentials_new)
|
||||
render signin_path(:login=>true)
|
||||
end
|
||||
|
||||
# Register a user for email activation.
|
||||
|
|
|
@ -79,6 +79,11 @@ class AdminController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 系统消息
|
||||
def messages
|
||||
@admin_messages = SystemMessage.new
|
||||
end
|
||||
|
||||
def plugins
|
||||
@plugins = Redmine::Plugin.all
|
||||
end
|
||||
|
@ -395,4 +400,78 @@ class AdminController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
#留言列表
|
||||
def leave_messages
|
||||
@jour = JournalsForMessage.find_by_sql("SELECT * FROM journals_for_messages AS j1
|
||||
WHERE j1.jour_type IN ('Course','Principal') AND (j1.m_parent_id IS NULL OR (j1.m_parent_id IN (SELECT id FROM journals_for_messages WHERE jour_type IN ('Course','Principal')))) order by created_on desc")
|
||||
@jour = paginateHelper @jour,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#帖子
|
||||
def messages_list
|
||||
@memo = Memo.reorder("created_at desc")
|
||||
@memo = paginateHelper @memo,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#课程讨论区的帖子
|
||||
def course_messages
|
||||
@course_ms=Message.joins("join boards on messages.board_id=boards.id where boards.course_id is not NULL").reorder('created_on desc')
|
||||
@course_ms = paginateHelper @course_ms,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
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')
|
||||
@project_ms = paginateHelper @project_ms,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#通知
|
||||
def notices
|
||||
@news = News.where('course_id is not NULL').order('created_on desc')
|
||||
@news = paginateHelper @news,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#最近登录用户列表
|
||||
def latest_login_users
|
||||
scope = User.order('last_login_on desc')
|
||||
scope = scope.where("last_login_on>= '#{params[:startdate]} 00:00:00'") if params[:startdate].present?
|
||||
scope =scope.where("last_login_on <= '#{params[:enddate]} 23:59:59'") if params[:enddate].present?
|
||||
@user = scope
|
||||
@user = paginateHelper @user,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#作业
|
||||
def homework
|
||||
@homework = HomeworkCommon.order('end_time desc')
|
||||
@homework = paginateHelper @homework,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -557,12 +557,13 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def redirect_back_or_default(default, options={})
|
||||
back_url = params[:back_url].to_s
|
||||
back_url = '' #params[:back_url].to_s
|
||||
if back_url.present?
|
||||
begin
|
||||
uri = URI.parse(back_url)
|
||||
# do not redirect user to another host or to the login or register page
|
||||
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
|
||||
back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(:User)
|
||||
redirect_to(back_url)
|
||||
return
|
||||
end
|
||||
|
|
|
@ -68,6 +68,28 @@ class BoardsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
# 讨论区消息状态更新(已读和未读)
|
||||
if @project
|
||||
query_forge_messages = @board.messages
|
||||
query_forge_messages.each do |query_forge_message|
|
||||
query = query_forge_message.forge_messages
|
||||
query.each do |forge_message|
|
||||
if User.current.id == forge_message.user_id
|
||||
forge_message.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif @course
|
||||
query_course_messages = @board.messages
|
||||
query_course_messages.each do |query_course_message|
|
||||
query = query_course_message.course_messages
|
||||
query.each do |course_message|
|
||||
if User.current.id == course_message.user_id
|
||||
course_message.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {
|
||||
|
@ -79,8 +101,9 @@ class BoardsController < ApplicationController
|
|||
@topic_count = @board ? @board.topics.count : 0
|
||||
if @project
|
||||
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
|
||||
#现在发布帖子的时候置顶功能已经没有了。所以取消这个置顶排序 #{Message.table_name}.sticky DESC,
|
||||
@topics = @board.topics.
|
||||
reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc").
|
||||
reorder("#{Message.table_name}.created_on desc").
|
||||
includes(:last_reply).
|
||||
limit(@topic_pages.per_page).
|
||||
offset(@topic_pages.offset).
|
||||
|
|
|
@ -34,24 +34,41 @@ class CommentsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
if( @comment.id && @news.course )
|
||||
if(@news.author_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
notify.activity_container_id = @news.course.id
|
||||
notify.activity_container_type = 'Course'
|
||||
notify.activity_id = @comment.id
|
||||
notify.activity_type = 'Comment'
|
||||
notify.notify_to = @news.author_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
# # <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
|
||||
# if( @comment.id && @news.course )
|
||||
# if(@news.author_id != User.current.id)
|
||||
# notify = ActivityNotify.new()
|
||||
# notify.activity_container_id = @news.course.id
|
||||
# notify.activity_container_type = 'Course'
|
||||
# notify.activity_id = @comment.id
|
||||
# notify.activity_type = 'Comment'
|
||||
# notify.notify_to = @news.author_id
|
||||
# notify.is_read = 0
|
||||
# notify.save()
|
||||
# end
|
||||
# end
|
||||
# # <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
course_activity = CourseActivity.where("course_act_type='News' and course_act_id =#{@news.id}").first
|
||||
if course_activity
|
||||
course_activity.updated_at = Time.now
|
||||
course_activity.save
|
||||
end
|
||||
user_activity = UserActivity.where("act_type='News' and act_id =#{@news.id}").first
|
||||
if user_activity
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to news_url(@news)
|
||||
if params[:user_activity_id]
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
else
|
||||
redirect_to news_url(@news)
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
@ -8,7 +8,7 @@ class CoursesController < ApplicationController
|
|||
helper :attachments
|
||||
helper :activity_notifys
|
||||
|
||||
before_filter :auth_login1, :only => [:show, :feedback]
|
||||
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
|
||||
menu_item :overview
|
||||
menu_item :feedback, :only => :feedback
|
||||
menu_item :homework, :only => :homework
|
||||
|
@ -39,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|
|
||||
|
@ -101,74 +106,18 @@ 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
|
||||
|
||||
@name = params[:name]
|
||||
@type = 'courses'
|
||||
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
|
||||
|
@ -519,13 +468,17 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@course_type = params[:course_type] ||= params[:course]
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@course = Course.new
|
||||
@course.safe_attributes = params[:course]
|
||||
# month = Time.now.month
|
||||
render :layout => 'new_base'
|
||||
if User.current.login?
|
||||
@course_type = params[:course_type] ||= params[:course]
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
@course = Course.new
|
||||
@course.safe_attributes = params[:course]
|
||||
# month = Time.now.month
|
||||
render :layout => 'new_base'
|
||||
else
|
||||
redirect_to signin_url
|
||||
end
|
||||
end
|
||||
|
||||
def desc_sort_course_by_avtivity(activity_count, courses)
|
||||
|
@ -657,94 +610,37 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
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)
|
||||
def course_activity
|
||||
redirect_to course_url(@course, type: params[:type], page: params[:page])
|
||||
end
|
||||
|
||||
@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?
|
||||
def show
|
||||
course_activities = @course.course_activities
|
||||
@canShowRealName = User.current.member_of_course? @course
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "homework"
|
||||
@course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "news"
|
||||
@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "message"
|
||||
@course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "poll"
|
||||
@course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "attachment"
|
||||
@course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "journalsForMessage"
|
||||
@course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
else
|
||||
@course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10)
|
||||
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
|
||||
@course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10)
|
||||
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
|
||||
|
||||
|
||||
@type = params[:type]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html{render :layout => 'base_courses'}
|
||||
format.api
|
||||
end
|
||||
|
@ -761,6 +657,11 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
def feedback
|
||||
@course.journals_for_messages.each do |messages|
|
||||
query = messages.course_messages.where("user_id = ?", User.current.id)
|
||||
query.update_all(:viewed => true);
|
||||
end
|
||||
|
||||
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||
page = params[:page]
|
||||
# Find the page of the requested reply
|
||||
|
|
|
@ -134,8 +134,12 @@ class FilesController < ApplicationController
|
|||
if sort == ""
|
||||
sort = "created_on DESC"
|
||||
end
|
||||
if keywords != "%%"
|
||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").
|
||||
reorder(sort)
|
||||
else
|
||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
|
||||
end
|
||||
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
|
||||
end
|
||||
|
||||
|
@ -176,12 +180,6 @@ 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 = ""
|
||||
@sort = ""
|
||||
@order = ""
|
||||
|
@ -553,7 +551,7 @@ class FilesController < ApplicationController
|
|||
q = "%#{@q.strip}%"
|
||||
@result = find_course_attache q,@course,sort
|
||||
@result = visable_attachemnts @result
|
||||
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)}
|
||||
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
|
||||
@searched_attach = paginateHelper @result,10
|
||||
@tag_list = get_course_tag_list @course
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class ForumsController < ApplicationController
|
|||
before_filter :find_forum_if_available
|
||||
before_filter :authenticate_user_edit, :only => [:edit, :update]
|
||||
before_filter :authenticate_user_destroy, :only => [:destroy]
|
||||
before_filter :require_login, :only => [:new, :create]
|
||||
before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit]
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
|
@ -97,7 +97,24 @@ class ForumsController < ApplicationController
|
|||
|
||||
def index
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@forums_all = Forum.reorder("sticky DESC")
|
||||
if(params[:reorder_complex])
|
||||
@type="reorder_complex"
|
||||
@str=params[:reorder_complex]
|
||||
@forums_all = Forum.reorder("topic_count #{params[:reorder_complex]},updated_at #{params[:reorder_complex]}")
|
||||
elsif(params[:reorder_popu])
|
||||
@type="reorder_popu"
|
||||
@str=params[:reorder_popu]
|
||||
@forums_all = Forum.reorder("topic_count #{params[:reorder_popu]}")
|
||||
elsif(params[:reorder_time])
|
||||
@type="reorder_time"
|
||||
@str=params[:reorder_time]
|
||||
@forums_all = Forum.reorder("updated_at #{params[:reorder_time]}")
|
||||
else
|
||||
params[:reorder_complex] = "desc"
|
||||
@type="reorder_complex"
|
||||
@str=params[:reorder_complex]
|
||||
@forums_all = Forum.reorder("topic_count desc,updated_at desc")
|
||||
end
|
||||
@forums_count = @forums_all.count
|
||||
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
||||
|
||||
|
@ -106,6 +123,7 @@ class ForumsController < ApplicationController
|
|||
#@forums = Forum.all
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.js
|
||||
format.json { render json: @forums }
|
||||
end
|
||||
end
|
||||
|
@ -113,11 +131,25 @@ class ForumsController < ApplicationController
|
|||
# GET /forums/1
|
||||
# GET /forums/1.json
|
||||
def show
|
||||
sort_init 'updated_at', 'desc'
|
||||
sort_update 'created_at' => "#{Memo.table_name}.created_at",
|
||||
'replies' => "#{Memo.table_name}.replies_count",
|
||||
'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)"
|
||||
|
||||
# sort_init 'updated_at', 'desc'
|
||||
# sort_update 'created_at' => "#{Memo.table_name}.created_at",
|
||||
# 'replies' => "#{Memo.table_name}.replies_count",
|
||||
# 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)"
|
||||
order = ""
|
||||
@order_str = ""
|
||||
if(params[:reorder_complex])
|
||||
order = " last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}"
|
||||
@order_str = "reorder_complex="+params[:reorder_complex]
|
||||
elsif(params[:reorder_popu])
|
||||
order = "replies_count #{params[:reorder_popu]}"
|
||||
@order_str = "reorder_popu="+params[:reorder_popu]
|
||||
elsif(params[:reorder_time])
|
||||
order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}"
|
||||
@order_str = "reorder_time="+params[:reorder_time]
|
||||
else
|
||||
order = "last_replies_memos.created_at desc, #{Memo.table_name}.created_at desc"
|
||||
@order_str = "reorder_complex=desc"
|
||||
end
|
||||
@memo = Memo.new(:forum => @forum)
|
||||
@topic_count = @forum.topics.count
|
||||
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
|
||||
|
@ -126,19 +158,15 @@ class ForumsController < ApplicationController
|
|||
includes(:last_reply).
|
||||
limit(@topic_pages.per_page).
|
||||
offset(@topic_pages.offset).
|
||||
order(sort_clause).
|
||||
reorder(order).
|
||||
preload(:author, {:last_reply => :author}).
|
||||
all
|
||||
@memos
|
||||
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
# @forum = Forum.find(params[:id])
|
||||
# @memos_all = @forum.topics
|
||||
# @topic_count = @memos_all.count
|
||||
# @topic_pages = Paginator.new @topic_count, @limit, params['page']
|
||||
|
||||
# @offset ||= @topic_pages.offset
|
||||
# @memos = @memos_all.offset(@offset).limit(@limit).all
|
||||
@my_topic_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is null").count
|
||||
@my_replies_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is not null").count
|
||||
@errors = params[:errors]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {
|
||||
render :layout => 'base_forums'
|
||||
}# show.html.erb
|
||||
|
@ -172,20 +200,23 @@ class ForumsController < ApplicationController
|
|||
# Author lizanle
|
||||
# Description after save后需要进行资源记录的更新
|
||||
# owner_type = 2 对应的是 forum
|
||||
@save_flag=true
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM
|
||||
end
|
||||
#end
|
||||
respond_to do |format|
|
||||
|
||||
format.js
|
||||
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
|
||||
format.json { render json: @forum, status: :created, location: @forum }
|
||||
end
|
||||
|
||||
else
|
||||
@save_flag=false
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}"
|
||||
format.js
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
@ -199,10 +230,12 @@ class ForumsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @forum.update_attributes(params[:forum])
|
||||
format.js {render :text=> true}
|
||||
format.html { redirect_to @forum, notice: l(:label_forum_update_succ) }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
flash.now[:error] = "#{l :label_forum_update_fail}: #{@forum.errors.full_messages[0]}"
|
||||
format.js { render :text=> false}
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
@ -261,6 +294,52 @@ class ForumsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#检查forum的名字
|
||||
def check_forum_name
|
||||
forum_name_exist = true
|
||||
if params[:forum_id]
|
||||
forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false
|
||||
else
|
||||
forum_name_exist = Forum.where("name = '#{params[:forum_name]}' ").count >= 1 ? true : false
|
||||
end
|
||||
render :text => forum_name_exist
|
||||
end
|
||||
|
||||
#添加论坛tag
|
||||
def add_forum_tag
|
||||
@forum = Forum.find(params[:id])
|
||||
unless @forum.nil?
|
||||
@forum.tag_list.add(params[:tag_str].split(','))
|
||||
@forum.save
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js {render :delete_forum_tag}
|
||||
end
|
||||
end
|
||||
|
||||
#删除forum的tag
|
||||
def delete_forum_tag
|
||||
@tag_id = (ActsAsTaggableOn::Tag.find_by_name(params[:tag_name])).id
|
||||
#forum的taggable_type = 5
|
||||
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,params[:id],'Forum')
|
||||
|
||||
unless @taggings.nil?
|
||||
@taggings.delete
|
||||
end
|
||||
|
||||
# 是否还有其他记录 引用了 tag_id
|
||||
@tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
|
||||
# 如果taggings表中记录已经不存在 ,那么检查tags表 作删除动作
|
||||
if @tagging.nil?
|
||||
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
|
||||
@tag.delete unless @tag.nil?
|
||||
end
|
||||
@forum = Forum.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_forum_if_available
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#added by baiyu
|
||||
class GitUsageController < ApplicationController
|
||||
layout "new_base"
|
||||
def ch_usage
|
||||
|
||||
end
|
||||
|
||||
def en_usage
|
||||
|
||||
end
|
||||
end
|
||||
#end
|
|
@ -3,282 +3,86 @@ class HomeworkCommonController < ApplicationController
|
|||
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]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
|
||||
|
||||
include StudentWorkHelper
|
||||
before_filter :find_course, :only => [:index,:new,:create]
|
||||
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr]
|
||||
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr]
|
||||
before_filter :member_of_course, :only => [:index]
|
||||
|
||||
def index
|
||||
homeworks = @course.homework_commons.order("created_at desc")
|
||||
@new_homework = HomeworkCommon.new
|
||||
@new_homework.homework_detail_manual = HomeworkDetailManual.new
|
||||
@new_homework.course = @course
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
|
||||
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
|
||||
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
||||
@homeworks = paginateHelper homeworks,20
|
||||
@is_new = params[:is_new]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#新建作业,在个人作业列表创建作业
|
||||
def new
|
||||
# @homework_type = "1"
|
||||
#
|
||||
# @homework = HomeworkCommon.new
|
||||
# @homework.safe_attributes = params[:homework_common]
|
||||
# @homework.late_penalty = 0
|
||||
# @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
# @homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
#
|
||||
# if @homework_type == "1"
|
||||
# #匿评作业相关属性
|
||||
# @homework_detail_manual = HomeworkDetailManual.new
|
||||
# @homework_detail_manual.ta_proportion = 0.6
|
||||
# @homework_detail_manual.absence_penalty = 0
|
||||
# @homework_detail_manual.evaluation_num = 3
|
||||
# @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
# @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
# @homework.homework_detail_manual = @homework_detail_manual
|
||||
# elsif @homework_type == "2"
|
||||
# #编程作业相关属性
|
||||
# @homework_detail_programing = HomeworkDetailPrograming.new
|
||||
# @homework.homework_detail_programing = @homework_detail_programing
|
||||
# end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
#新建作业下一步
|
||||
def next_step
|
||||
@homework_type = params[:homework_common_type]
|
||||
|
||||
@homework = HomeworkCommon.new
|
||||
@homework.safe_attributes = params[:homework_common]
|
||||
@homework.late_penalty = 0
|
||||
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
|
||||
|
||||
if @homework_type == "1"
|
||||
#匿评作业相关属性
|
||||
@homework_detail_manual = HomeworkDetailManual.new
|
||||
@homework_detail_manual.ta_proportion = 0.6
|
||||
@homework_detail_manual.absence_penalty = 0
|
||||
@homework_detail_manual.evaluation_num = 3
|
||||
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
|
||||
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
|
||||
@homework.homework_detail_manual = @homework_detail_manual
|
||||
elsif @homework_type == "2"
|
||||
#编程作业相关属性
|
||||
@homework_detail_programing = HomeworkDetailPrograming.new
|
||||
@homework.homework_detail_programing = @homework_detail_programing
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
render_404
|
||||
end
|
||||
|
||||
#新建作业,在个人作业列表创建作业
|
||||
def create
|
||||
if params[:homework_common]
|
||||
homework = HomeworkCommon.new
|
||||
homework.name = params[:homework_common][:name]
|
||||
homework.description = params[:homework_common][:description]
|
||||
homework.end_time = params[:homework_common][:end_time]
|
||||
homework.publish_time = params[:homework_common][:publish_time]
|
||||
homework.homework_type = params[:homework_common][:homework_type]
|
||||
homework.late_penalty = params[:late_penalty]
|
||||
homework.user_id = User.current.id
|
||||
homework.course_id = @course.id
|
||||
|
||||
homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(homework)
|
||||
|
||||
if homework.homework_type == 2
|
||||
homework_detail_programing = HomeworkDetailPrograming.new
|
||||
homework_detail_programing.language = params[:language]
|
||||
homework_detail_programing.standard_code = params[:standard_code]
|
||||
homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||
question = {title:homework.name,content:homework.description}
|
||||
question[:input] = []
|
||||
question[:output] = []
|
||||
if params[:input] && params[:output] && params[:result]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.result = params[:result][k]
|
||||
homework.homework_tests << homework_test
|
||||
question[:input] << homework_test.input
|
||||
question[:output] << homework_test.output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# uri = URI('http://test.gitlab.trustie.net/api/questions.json')
|
||||
# req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})
|
||||
# req.body = question.to_json
|
||||
# res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
||||
# http.request(req)
|
||||
# end
|
||||
|
||||
uri = URI('http://192.168.80.21:8080/api/questions.json')
|
||||
body = question.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
||||
|
||||
homework.homework_detail_programing = homework_detail_programing
|
||||
else
|
||||
#匿评作业相关属性
|
||||
homework_detail_manual = HomeworkDetailManual.new
|
||||
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_detail_manual.comment_status = 1
|
||||
homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
homework.homework_detail_manual = homework_detail_manual
|
||||
end
|
||||
|
||||
if homework.save
|
||||
homework_detail_programing.save if homework_detail_programing
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to homework_common_index_path(:course => @course.id)
|
||||
}
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_failed_create)
|
||||
redirect_to new_homework_common_path(:course => @course.id)
|
||||
}
|
||||
end
|
||||
redirect_to user_homeworks_user_path(User.current.id)
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.current
|
||||
@is_in_course = params[:is_in_course].to_i
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.html{render :layout => 'new_base_user'}
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@homework.name = params[:homework_common][:name]
|
||||
@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] if params[:homework_common][:homework_type]
|
||||
unless @homework.late_penalty == params[:late_penalty]
|
||||
@homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work|
|
||||
student_work.late_penalty = params[:late_penalty]
|
||||
student_work.save
|
||||
end
|
||||
@homework.late_penalty = params[:late_penalty]
|
||||
end
|
||||
# @homework.course_id = @course.id
|
||||
if params[:homework_common]
|
||||
@homework.name = params[:homework_common][:name]
|
||||
@homework.description = params[:homework_common][:description]
|
||||
@homework.end_time = params[:homework_common][:end_time] || Time.now
|
||||
@homework.course_id = params[:course_id]
|
||||
|
||||
#匿评作业相关属性
|
||||
if @homework.homework_type == 1 && @homework_detail_manual
|
||||
@homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
@homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
@homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
unless @homework_detail_manual.absence_penalty == params[:absence_penalty]
|
||||
if @homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@homework.student_works.each do |student_work|
|
||||
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
|
||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
end
|
||||
@homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
end
|
||||
elsif @homework.homework_type == 0 #普通作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业
|
||||
@homework.student_works.where("absence_penalty != 0").each do |student_work|
|
||||
student_work.late_penalty = 0
|
||||
student_work.save
|
||||
end
|
||||
@homework_detail_manual.absence_penalty = 0 if @homework_detail_manual
|
||||
end
|
||||
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
|
||||
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start]
|
||||
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
|
||||
|
||||
if @homework.homework_type == 2 && @homework_detail_programing #编程作业
|
||||
@homework_detail_programing.language = params[:language]
|
||||
@homework_detail_programing.standard_code = params[:standard_code]
|
||||
@homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_tests = @homework.homework_tests
|
||||
#需要删除的测试
|
||||
ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i)
|
||||
ids.each do |id|
|
||||
homework_test = HomeworkTest.find id
|
||||
homework_test.destroy if homework_test
|
||||
end
|
||||
if params[:input] && params[:output]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
homework_test = HomeworkTest.find_by_id k
|
||||
if homework_test #已存在的测试,修改
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
else #不存在的测试,增加
|
||||
homework_test = HomeworkTest.new
|
||||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework_test.homework_common = @homework
|
||||
@homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@homework)
|
||||
|
||||
#编程作业相关属性
|
||||
if @homework.homework_type == 2
|
||||
@homework.homework_detail_programing ||= HomeworkDetailPrograming.new
|
||||
@homework_detail_programing = @homework.homework_detail_programing
|
||||
@homework_detail_programing.language = params[:language_type].to_i
|
||||
|
||||
@homework.homework_tests.delete_all
|
||||
inputs = params[:program][:input]
|
||||
if Array === inputs
|
||||
inputs.each_with_index do |val, i|
|
||||
@homework.homework_tests << HomeworkTest.new(
|
||||
input: val,
|
||||
output: params[:program][:output][i]
|
||||
)
|
||||
end
|
||||
homework_test.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#发送修改作业的请求
|
||||
question = {title:@homework.name,content:@homework.description}
|
||||
question[:input] = []
|
||||
question[:output] = []
|
||||
@homework.homework_tests.each do |test|
|
||||
question[:input] << test.input
|
||||
question[:output] << test.output
|
||||
end
|
||||
uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json")
|
||||
body = question.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Put.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
result = JSON.parse(res.body)
|
||||
end
|
||||
|
||||
@homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@homework)
|
||||
|
||||
if @homework.save
|
||||
@homework_detail_manual.save if @homework_detail_manual
|
||||
@homework_detail_programing.save if @homework_detail_programing
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_edit)
|
||||
if @homework.save
|
||||
@homework_detail_manual.save if @homework_detail_manual
|
||||
@homework_detail_programing.save if @homework_detail_programing
|
||||
if params[:is_in_course] == "1"
|
||||
redirect_to homework_common_index_path(:course => @course.id)
|
||||
}
|
||||
end
|
||||
return
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_failed_edit)
|
||||
redirect_to edit_homework_common_path(@homework)
|
||||
}
|
||||
else
|
||||
redirect_to user_homeworks_user_path(User.current.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -286,7 +90,13 @@ class HomeworkCommonController < ApplicationController
|
|||
def destroy
|
||||
if @homework.destroy
|
||||
respond_to do |format|
|
||||
format.html {redirect_to homework_common_index_path(:course => @course.id)}
|
||||
format.html {
|
||||
if params[:is_in_course] == "1"
|
||||
redirect_to homework_common_index_path(:course => @course.id)
|
||||
else
|
||||
redirect_to user_homeworks_user_path(User.current.id)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -294,11 +104,11 @@ class HomeworkCommonController < ApplicationController
|
|||
#开启匿评
|
||||
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
|
||||
def start_anonymous_comment
|
||||
@statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
|
||||
@statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
|
||||
@statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
if @homework_detail_manual.comment_status == 1
|
||||
student_works = @homework.student_works
|
||||
if student_works && student_works.size >=2
|
||||
if student_works && student_works.size >= 2
|
||||
student_works.each_with_index do |work, index|
|
||||
user = work.user
|
||||
n = @homework_detail_manual.evaluation_num
|
||||
|
@ -311,6 +121,9 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
@homework_detail_manual.update_column('comment_status', 2)
|
||||
@statue = 1
|
||||
# 匿评开启消息邮件通知
|
||||
send_message_anonymous_comment(@homework, m_status = 2)
|
||||
Mailer.send_mail_anonymous_comment_open(@homework).deliver
|
||||
else
|
||||
@statue = 2
|
||||
end
|
||||
|
@ -322,19 +135,29 @@ class HomeworkCommonController < ApplicationController
|
|||
#关闭匿评
|
||||
def stop_anonymous_comment
|
||||
@homework_detail_manual.update_column('comment_status', 3)
|
||||
|
||||
#计算缺评扣分
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@homework.student_works.each do |student_work|
|
||||
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
|
||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
|
||||
# 匿评关闭消息邮件通知
|
||||
send_message_anonymous_comment(@homework, m_status = 3)
|
||||
Mailer.send_mail_anonymous_comment_close(@homework).deliver
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 开启/关闭匿评消息通知
|
||||
def send_message_anonymous_comment(homework, m_status )
|
||||
# status 标记匿评状态 1为关闭 0为开启
|
||||
course = homework.course
|
||||
course.members.each do |m|
|
||||
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status)
|
||||
end
|
||||
end
|
||||
#提示
|
||||
def alert_anonymous_comment
|
||||
@cur_size = 0
|
||||
|
@ -365,11 +188,33 @@ class HomeworkCommonController < ApplicationController
|
|||
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
|
||||
|
||||
#启动匿评参数设置
|
||||
def start_evaluation_set
|
||||
|
||||
end
|
||||
|
||||
#设置匿评参数
|
||||
def set_evaluation_attr
|
||||
if @homework_detail_manual
|
||||
unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s
|
||||
@homework_detail_manual.evaluation_start = params[:evaluation_start]
|
||||
end
|
||||
|
||||
unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s
|
||||
@homework_detail_manual.evaluation_end = params[:evaluation_end]
|
||||
end
|
||||
|
||||
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
@homework_detail_manual.save
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取课程
|
||||
def find_course
|
||||
|
|
|
@ -20,11 +20,11 @@ class IssuesController < ApplicationController
|
|||
default_search_scope :issues
|
||||
|
||||
before_filter :authorize1, :only => [:show]
|
||||
before_filter :find_issue, :only => [:show, :edit, :update]
|
||||
before_filter :find_issue, :only => [:show, :edit, :update,:add_journal]
|
||||
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||
before_filter :find_project, :only => [:new, :create, :update_form]
|
||||
#before_filter :authorize, :except => [:index, :show]
|
||||
before_filter :authorize, :except => [:index]
|
||||
before_filter :authorize, :except => [:index,:add_journal]
|
||||
|
||||
before_filter :find_optional_project, :only => [:index]
|
||||
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
||||
|
@ -66,14 +66,14 @@ class IssuesController < ApplicationController
|
|||
|
||||
if @query.valid?
|
||||
case params[:format]
|
||||
when 'csv', 'pdf'
|
||||
@limit = 10#Setting.issues_export_limit.to_i
|
||||
when 'atom'
|
||||
@limit = 10#Setting.feeds_limit.to_i
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
else
|
||||
@limit = 10#per_page_option
|
||||
when 'csv', 'pdf'
|
||||
@limit = 10#Setting.issues_export_limit.to_i
|
||||
when 'atom'
|
||||
@limit = 10#Setting.feeds_limit.to_i
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
else
|
||||
@limit = 10#per_page_option
|
||||
end
|
||||
@assign_to_id = params[:assigned_to_id]
|
||||
@author_id = params[:author_id]
|
||||
|
@ -84,9 +84,9 @@ class IssuesController < ApplicationController
|
|||
@issue_pages = Paginator.new @issue_count, @limit, params['page']
|
||||
@offset ||= @issue_pages.offset
|
||||
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
|
||||
:order => sort_clause,
|
||||
:offset => @offset,
|
||||
:limit => @limit)
|
||||
:order => sort_clause,
|
||||
:offset => @offset,
|
||||
:limit => @limit)
|
||||
@issue_count_by_group = @query.issue_count_by_group
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -112,7 +112,19 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
|
||||
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
|
||||
query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first
|
||||
query.update_attribute(:viewed, true) unless query.nil?
|
||||
# 缺陷状态更新
|
||||
query_journals = @issue.journals
|
||||
query_journals.each do |query_journal|
|
||||
query_journal.forge_messages.each do |f|
|
||||
if User.current.id == f.user_id
|
||||
f.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
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)
|
||||
|
@ -131,16 +143,16 @@ class IssuesController < ApplicationController
|
|||
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
|
||||
|
||||
respond_to do |format|``
|
||||
format.html {
|
||||
retrieve_previous_and_next_issue_ids
|
||||
render :template => 'issues/show', :layout => @project_base_tag#by young
|
||||
}
|
||||
format.api
|
||||
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
|
||||
format.pdf {
|
||||
pdf = issue_to_pdf(@issue, :journals => @journals)
|
||||
send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf")
|
||||
}
|
||||
format.html {
|
||||
retrieve_previous_and_next_issue_ids
|
||||
render :template => 'issues/show', :layout => @project_base_tag#by young
|
||||
}
|
||||
format.api
|
||||
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
|
||||
format.pdf {
|
||||
pdf = issue_to_pdf(@issue, :journals => @journals)
|
||||
send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -207,7 +219,6 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
if saved
|
||||
|
||||
#修改界面增加跟踪者
|
||||
watcherlist = @issue.watcher_users
|
||||
select_users = []
|
||||
|
@ -237,9 +248,7 @@ class IssuesController < ApplicationController
|
|||
JournalReply.add_reply(@issue.current_journal.id, reply_id, User.current.id)
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html { redirect_to issue_url(@issue.id) }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
|
@ -310,8 +319,8 @@ class IssuesController < ApplicationController
|
|||
issue.reload
|
||||
if @copy
|
||||
issue = issue.copy({},
|
||||
:attachments => params[:copy_attachments].present?,
|
||||
:subtasks => params[:copy_subtasks].present?
|
||||
:attachments => params[:copy_attachments].present?,
|
||||
:subtasks => params[:copy_subtasks].present?
|
||||
)
|
||||
end
|
||||
journal = issue.init_journal(User.current, params[:notes])
|
||||
|
@ -341,21 +350,21 @@ class IssuesController < ApplicationController
|
|||
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
|
||||
if @hours > 0
|
||||
case params[:todo]
|
||||
when 'destroy'
|
||||
# nothing to do
|
||||
when 'nullify'
|
||||
TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
|
||||
when 'reassign'
|
||||
reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
|
||||
if reassign_to.nil?
|
||||
flash.now[:error] = l(:error_issue_not_found_in_project)
|
||||
return
|
||||
when 'destroy'
|
||||
# nothing to do
|
||||
when 'nullify'
|
||||
TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
|
||||
when 'reassign'
|
||||
reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
|
||||
if reassign_to.nil?
|
||||
flash.now[:error] = l(:error_issue_not_found_in_project)
|
||||
return
|
||||
else
|
||||
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
|
||||
end
|
||||
else
|
||||
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
|
||||
end
|
||||
else
|
||||
# display the destroy form if it's a user request
|
||||
return unless api_request?
|
||||
# display the destroy form if it's a user request
|
||||
return unless api_request?
|
||||
end
|
||||
end
|
||||
@issues.each do |issue|
|
||||
|
@ -371,6 +380,23 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def add_journal
|
||||
if User.current.logged?
|
||||
jour = Journal.new
|
||||
jour.user_id = User.current.id
|
||||
jour.notes = params[:notes]
|
||||
jour.journalized = @issue
|
||||
jour.save
|
||||
user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first
|
||||
user_activity.updated_at = jour.created_on
|
||||
user_activity.save
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_project
|
||||
|
@ -411,14 +437,14 @@ class IssuesController < ApplicationController
|
|||
issue_attributes = params[:issue]
|
||||
if issue_attributes && params[:conflict_resolution]
|
||||
case params[:conflict_resolution]
|
||||
when 'overwrite'
|
||||
issue_attributes = issue_attributes.dup
|
||||
issue_attributes.delete(:lock_version)
|
||||
when 'add_notes'
|
||||
issue_attributes = issue_attributes.slice(:notes)
|
||||
when 'cancel'
|
||||
redirect_to issue_url(@issue)
|
||||
return false
|
||||
when 'overwrite'
|
||||
issue_attributes = issue_attributes.dup
|
||||
issue_attributes.delete(:lock_version)
|
||||
when 'add_notes'
|
||||
issue_attributes = issue_attributes.slice(:notes)
|
||||
when 'cancel'
|
||||
redirect_to issue_url(@issue)
|
||||
return false
|
||||
end
|
||||
end
|
||||
@issue.safe_attributes = issue_attributes
|
||||
|
|
|
@ -36,8 +36,7 @@ class JournalsController < ApplicationController
|
|||
sort_update(@query.sortable_columns)
|
||||
|
||||
if @query.valid?
|
||||
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
|
||||
:limit => 25)
|
||||
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC", :limit => 25)
|
||||
end
|
||||
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
|
||||
render :layout => false, :content_type => 'application/atom+xml'
|
||||
|
@ -72,9 +71,9 @@ class JournalsController < ApplicationController
|
|||
end
|
||||
# Replaces pre blocks with [...]
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
# @content = "<blockquote style='word-break: break-all;word-wrap: break-word;'>" << @content
|
||||
@content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n"
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n ") + "\n"
|
||||
@content = "<blockquote style='padding-left:0px;margin-left:0px;'>" << @content << "</blockquote>\n\n<br/>"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
|
|
|
@ -11,7 +11,7 @@ class MemosController < ApplicationController
|
|||
include AttachmentsHelper
|
||||
include ApplicationHelper
|
||||
|
||||
layout 'base_memos'
|
||||
# layout 'base_memos'
|
||||
|
||||
def quote
|
||||
@subject = @memo.subject
|
||||
|
@ -73,41 +73,14 @@ class MemosController < ApplicationController
|
|||
end
|
||||
end
|
||||
#end
|
||||
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
|
||||
format.json { render json: @memo, status: :created, location: @memo }
|
||||
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
|
||||
format.json { render json: @memo, status: :created, location: @memo }
|
||||
else
|
||||
flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
|
||||
# back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
|
||||
pre_count = REPLIES_PER_PAGE
|
||||
|
||||
@memo_new = @memo.dup
|
||||
@memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
||||
unless @memo.new_record?
|
||||
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
|
||||
end
|
||||
|
||||
|
||||
page = params[:page]
|
||||
if params[:r] && page.nil?
|
||||
offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count
|
||||
page = 1 + offset / pre_count
|
||||
else
|
||||
|
||||
end
|
||||
@reply_count = @memo.children.count
|
||||
@reply_pages = Paginator.new @reply_count, pre_count, page
|
||||
@replies = @memo.children.
|
||||
includes(:author, :attachments).
|
||||
reorder("#{Memo.table_name}.created_at DESC").
|
||||
limit(@reply_pages.per_page).
|
||||
offset(@reply_pages.offset).
|
||||
all
|
||||
if @memo.new_record?
|
||||
format.html { render :new,:layout=>'base'}
|
||||
else
|
||||
format.html { render action: :show }
|
||||
format.js
|
||||
format.html { redirect_to( forum_path(Forum.find(params[:forum_id]),:errors=>@memo.errors.full_messages[0])) }
|
||||
format.json { render json: @memo.errors, status: :unprocessable_entity }
|
||||
end
|
||||
#end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -115,8 +88,25 @@ class MemosController < ApplicationController
|
|||
|
||||
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
|
||||
def show
|
||||
pre_count = REPLIES_PER_PAGE
|
||||
|
||||
# 更新贴吧帖子留言对应的memo_messages的viewed字段
|
||||
unless @memo.children.blank?
|
||||
@memo.children.each do |child|
|
||||
child.memo_messages.each do |memo_message|
|
||||
if User.current.id == memo_message.user_id
|
||||
memo_message.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
query_memo_messages = @memo.memo_messages
|
||||
query_memo_messages.each do |query_memo_message|
|
||||
if User.current.id == query_memo_message.user_id
|
||||
query_memo_message.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
|
||||
pre_count = REPLIES_PER_PAGE
|
||||
@memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
||||
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
|
||||
|
||||
|
@ -138,21 +128,27 @@ class MemosController < ApplicationController
|
|||
|
||||
@memo_new = Memo.new
|
||||
|
||||
|
||||
@my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count
|
||||
@my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count
|
||||
# @memo = Memo.find_by_id(params[:id])
|
||||
# @forum = Forum.find(params[:forum_id])
|
||||
# @replies = @memo.replies
|
||||
# @mome_new = Memo.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.html {render :layout=> 'base_forums'}#:layout=> 'base_forums',
|
||||
format.json { render json: @memo }
|
||||
format.xml { render xml: @memo }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count
|
||||
@my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count
|
||||
@replying = false
|
||||
respond_to do |format|
|
||||
format.html {render :layout=>'base_forums'}
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -160,7 +156,8 @@ class MemosController < ApplicationController
|
|||
if( #@memo.update_column(:subject, params[:memo][:subject]) &&
|
||||
@memo.update_column(:content, params[:memo][:content]) &&
|
||||
@memo.update_column(:sticky, params[:memo][:sticky]) &&
|
||||
@memo.update_column(:lock, params[:memo][:lock]))
|
||||
@memo.update_column(:lock, params[:memo][:lock]) &&
|
||||
@memo.update_column(:subject,params[:memo][:subject]))
|
||||
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
|
||||
@memo.save
|
||||
# @memo.root.update_attribute(:updated_at, @memo.updated_at)
|
||||
|
@ -211,7 +208,7 @@ class MemosController < ApplicationController
|
|||
end
|
||||
|
||||
def back_memo_url
|
||||
forum_memo_path(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))
|
||||
forum_memo_path(@forum, (@memo.root.nil? ? @memo : @memo.root))
|
||||
end
|
||||
|
||||
def back_memo_or_forum_url
|
||||
|
|
|
@ -89,72 +89,54 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Create a new topic
|
||||
def new
|
||||
@message = Message.new
|
||||
@message.author = User.current
|
||||
@message.board = @board
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
# 与我相关动态的记录add start
|
||||
if(@board && @board.course) #项目的先不管
|
||||
teachers = searchTeacherAndAssistant(@board.course)
|
||||
for teacher in teachers
|
||||
if(teacher.user_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
if(@board.course)
|
||||
notify.activity_container_id = @board.course_id
|
||||
notify.activity_container_type = 'Course'
|
||||
else
|
||||
notify.activity_container_id = @board.project_id
|
||||
notify.activity_container_type = 'Project'
|
||||
end
|
||||
notify.activity_id = @message.id
|
||||
notify.activity_type = 'Message'
|
||||
notify.notify_to = teacher.user_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
if User.current.logged?
|
||||
@message = Message.new
|
||||
@message.author = User.current
|
||||
@message.board = @board
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course)
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course)
|
||||
end
|
||||
else
|
||||
redirect_to board_message_url(@board, @message)
|
||||
end
|
||||
else
|
||||
redirect_to board_message_url(@board, @message)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project, :flag => true)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course, :flag => true)
|
||||
end
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :action => 'new', :layout => layout_file
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project, :flag => true)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course, :flag => true)
|
||||
end
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :action => 'new', :layout => layout_file
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
redirect_to signin_path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -177,7 +159,19 @@ class MessagesController < ApplicationController
|
|||
@reply.board = @board
|
||||
@reply.safe_attributes = params[:reply]
|
||||
@reply.content = @quote + @reply.content
|
||||
@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
|
||||
# @reply.reply_id = params[:id]
|
||||
@topic.children << @reply
|
||||
course_activity = CourseActivity.where("course_act_type='Message' and course_act_id =#{@topic.id}").first
|
||||
if course_activity
|
||||
course_activity.updated_at = Time.now
|
||||
course_activity.save
|
||||
end
|
||||
user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first
|
||||
if user_activity
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
#@topic.update_attribute(:updated_on, Time.now)
|
||||
if !@reply.new_record?
|
||||
if params[:asset_id]
|
||||
|
@ -185,41 +179,18 @@ class MessagesController < ApplicationController
|
|||
update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
|
||||
# 与我相关动态的记录add start
|
||||
if(@board && @board.course) #项目的先不管
|
||||
notifyto_arr = {}
|
||||
notifyto_arr[@topic.author_id] = @topic.author_id
|
||||
if( params[:parent_topic] != nil && params[:parent_topic] != '')
|
||||
parent_topic = Message.find(params[:parent_topic])
|
||||
notifyto_arr[parent_topic.author_id] = parent_topic.author_id
|
||||
end
|
||||
notifyto_arr.each do |k,user_id|
|
||||
if(user_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
if(@board.course)
|
||||
notify.activity_container_id = @board.course_id
|
||||
notify.activity_container_type = 'Course'
|
||||
else
|
||||
notify.activity_container_id = @board.project_id
|
||||
notify.activity_container_type = 'Project'
|
||||
end
|
||||
notify.activity_id = @reply.id
|
||||
notify.activity_type = 'Message'
|
||||
notify.notify_to = user_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
end
|
||||
# 与我相关动态的记录add end
|
||||
|
||||
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
||||
attachments = Attachment.attach_files(@reply, params[:attachments])
|
||||
render_attachment_warning_if_needed(@reply)
|
||||
else
|
||||
#render file: 'messages#show', layout: 'base_courses'
|
||||
end
|
||||
if params[:is_board]
|
||||
if params[:user_activity_id]
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
elsif params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project)
|
||||
elsif @course
|
||||
|
|
|
@ -137,7 +137,7 @@ 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.brief_introduction = params[:brief_introduction]
|
||||
@se.description = params[:description]
|
||||
|
||||
if @user.save && @se.save
|
||||
|
@ -157,7 +157,7 @@ class MyController < ApplicationController
|
|||
File.delete(diskfile1) if File.exist?(diskfile1)
|
||||
end
|
||||
|
||||
render :layout=>'base_users_new'
|
||||
render :layout=>'new_base_user'
|
||||
end
|
||||
|
||||
# Destroys user's account
|
||||
|
@ -174,7 +174,7 @@ class MyController < ApplicationController
|
|||
logout_user
|
||||
flash.now[:notice] = l(:notice_account_deleted)
|
||||
end
|
||||
redirect_to home_url
|
||||
redirect_to signin_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class NewsController < ApplicationController
|
|||
|
||||
@news_count = scope.count
|
||||
@q = params[:subject]
|
||||
if params[:subject].nil?
|
||||
if params[:subject].nil? || params[:subject].blank?
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
else
|
||||
|
@ -99,6 +99,33 @@ class NewsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
# 更新news对应的forge_messages的消息viewed字段
|
||||
if @project
|
||||
query_message_news = @news.forge_messages
|
||||
else
|
||||
query_message_news = @news.course_messages
|
||||
end
|
||||
query_message_news.each do |query|
|
||||
if User.current.id == query.user_id
|
||||
query.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
# 更新项目新闻的评阅的消息viewed字段
|
||||
current_message_comments = @news.comments
|
||||
current_message_comments.each do |current_message_comment|
|
||||
if @project
|
||||
query_message_comment = current_message_comment.forge_messages
|
||||
else
|
||||
query_message_comment = current_message_comment.course_messages
|
||||
end
|
||||
query_message_comment.each do |query|
|
||||
if User.current.id == query.user_id
|
||||
query.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
|
||||
cs = CoursesService.new
|
||||
result = cs.show_course_news params,User.current
|
||||
@news = result[:news]
|
||||
|
@ -148,19 +175,19 @@ class NewsController < ApplicationController
|
|||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
|
||||
teachers = searchTeacherAndAssistant(@course)
|
||||
for teacher in teachers
|
||||
if(teacher.user_id != User.current.id)
|
||||
notify = ActivityNotify.new()
|
||||
notify.activity_container_id = @course.id
|
||||
notify.activity_container_type = 'Course'
|
||||
notify.activity_id = @news.id
|
||||
notify.activity_type = 'News'
|
||||
notify.notify_to = teacher.user_id
|
||||
notify.is_read = 0
|
||||
notify.save()
|
||||
end
|
||||
end
|
||||
# teachers = searchTeacherAndAssistant(@course)
|
||||
# for teacher in teachers
|
||||
# if(teacher.user_id != User.current.id)
|
||||
# notify = ActivityNotify.new()
|
||||
# notify.activity_container_id = @course.id
|
||||
# notify.activity_container_type = 'Course'
|
||||
# notify.activity_id = @news.id
|
||||
# notify.activity_type = 'News'
|
||||
# notify.notify_to = teacher.user_id
|
||||
# notify.is_read = 0
|
||||
# notify.save()
|
||||
# end
|
||||
# end
|
||||
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
|
||||
render_attachment_warning_if_needed(@news)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
|
|
@ -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]
|
||||
|
@ -27,6 +28,13 @@ class PollController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
# 问卷消息状态更新
|
||||
query_course_poll = @poll.course_messages
|
||||
query_course_poll.each do |query|
|
||||
if User.current.id == query.user_id
|
||||
query.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
#已提交问卷的用户不能再访问该界面
|
||||
if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
|
||||
redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id)
|
||||
|
@ -410,6 +418,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]
|
||||
|
|
|
@ -33,7 +33,7 @@ class ProjectsController < ApplicationController
|
|||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
||||
before_filter :file, :statistics #:watcherlist
|
||||
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
|
||||
before_filter :memberAccess, only: :member
|
||||
# before_filter :memberAccess, only: :member
|
||||
|
||||
# accept_rss_auth :index
|
||||
accept_api_auth :index, :show, :create, :update, :destroy
|
||||
|
@ -86,8 +86,15 @@ 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']
|
||||
@name = params[:name]
|
||||
@type = 'projects'
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base'
|
||||
|
@ -155,7 +162,7 @@ class ProjectsController < ApplicationController
|
|||
@trackers = Tracker.sorted.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
render :layout => 'base'
|
||||
render :layout => 'new_base'
|
||||
else
|
||||
redirect_to signin_url
|
||||
end
|
||||
|
@ -181,7 +188,8 @@ class ProjectsController < ApplicationController
|
|||
@project.safe_attributes = params[:project]
|
||||
@project.organization_id = params[:organization_id]
|
||||
@project.user_id = User.current.id
|
||||
@project.project_new_type = 1
|
||||
@project.project_new_type = params[:project_new_type]
|
||||
params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0
|
||||
if validate_parent_id && @project.save
|
||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||
# Add current user as a project member if he is not admin
|
||||
|
@ -209,10 +217,11 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
||||
format.js
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'base'}#Added by young
|
||||
format.html { render :action => 'new', :layout => 'new_base'}#Added by young
|
||||
format.api { render_validation_errors(@project) }
|
||||
end
|
||||
end
|
||||
|
@ -251,7 +260,8 @@ class ProjectsController < ApplicationController
|
|||
# Author lizanle
|
||||
# Description 项目动态展示方法,删除了不必要的代码
|
||||
def show
|
||||
|
||||
# 更新消息为已读
|
||||
update_message_status(User.current, @project)
|
||||
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
|
||||
return
|
||||
end
|
||||
|
@ -315,6 +325,12 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def settings
|
||||
# 修改查看消息状态
|
||||
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
|
||||
applied_messages.each do |applied_message|
|
||||
applied_message.update_attributes(:viewed => true)
|
||||
end
|
||||
# end
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @project.members.new
|
||||
|
@ -335,7 +351,7 @@ class ProjectsController < ApplicationController
|
|||
if params[:repository] == "pswd_is_null"
|
||||
html << l(:label_password_not_null)
|
||||
end
|
||||
flash[:error] = html if !html.to_s.blank?
|
||||
flash.now[:error] = html if !html.to_s.blank?
|
||||
end
|
||||
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
|
||||
@repository = Repository.factory(scm)
|
||||
|
@ -344,24 +360,60 @@ class ProjectsController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
# 项目邀请用户加入实现过程
|
||||
# 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定)
|
||||
def send_mail_to_member
|
||||
# 该邮箱未注册过
|
||||
if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil?
|
||||
email = params[:mail]
|
||||
Mailer.run.send_invite_in_project(email, @project, User.current)
|
||||
@is_zhuce = false
|
||||
flash[:notice] = l(:notice_email_sent, :value => email)
|
||||
if !User.where("login =?", params[:mail]).first.nil?
|
||||
# 用户名唯一,用户修改邮箱,未修改用户名,用户名等同邮箱的情况,默认改用户已经注册
|
||||
user = User.find_by_login(params[:mail].to_s)
|
||||
if !user.member_of?(@project)
|
||||
# 如果已经邀请过该用户,则不重复发送
|
||||
if InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first.nil?
|
||||
email = params[:mail]
|
||||
Mailer.request_member_to_project(email, @project, User.current).deliver
|
||||
flash[:notice] = l(:notice_email_sent, :value => email)
|
||||
else
|
||||
flash[:error] = l(:notice_email_invited)
|
||||
end
|
||||
else
|
||||
flash[:error] = l(:label_member_of_project, :value => email)
|
||||
end
|
||||
else
|
||||
email = params[:mail]
|
||||
first_name = params[:first_name]
|
||||
last_name = params[:last_name]
|
||||
gender = params[:gender]
|
||||
Mailer.send_invite_in_project(email, @project, User.current, first_name, last_name, gender).deliver
|
||||
@is_zhuce = false
|
||||
flash[:notice] = l(:notice_email_sent, :value => email)
|
||||
end
|
||||
|
||||
# 邮箱地址已被注册
|
||||
elsif !User.find_by_mail(params[:mail].to_s).nil?
|
||||
user = User.find_by_mail(params[:mail].to_s)
|
||||
if !user.member_of?(@project)
|
||||
email = params[:mail]
|
||||
Mailer.run.request_member_to_project(email, @project, User.current)
|
||||
flash[:notice] = l(:notice_email_sent, :value => email)
|
||||
# 如果已经邀请过该用户,则不重复发送
|
||||
invite_list = InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first
|
||||
if invite_list.nil?
|
||||
email = params[:mail]
|
||||
Mailer.request_member_to_project(email, @project, User.current).deliver
|
||||
flash[:notice] = l(:notice_email_sent, :value => email)
|
||||
else
|
||||
# 已经发送过了,则隔3小时才能再次发送
|
||||
if Time.now - invite_list.created_at > 10800
|
||||
email = params[:mail]
|
||||
Mailer.request_member_to_project(email, @project, User.current).deliver
|
||||
flash[:notice] = l(:notice_email_sent, :value => email)
|
||||
else
|
||||
flash[:error] = l(:notice_email_invited)
|
||||
end
|
||||
end
|
||||
else
|
||||
flash[:error] = l(:label_member_of_project, :value => email)
|
||||
end
|
||||
else
|
||||
flash[:error] = l(:notice_registed_error, :value => email)
|
||||
@is_zhuce = true
|
||||
end
|
||||
respond_to do |format|
|
||||
|
@ -369,56 +421,26 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# dts测试工具
|
||||
def dts_dep
|
||||
render_403 unless User.current.admin?
|
||||
@dts = Dts.all
|
||||
end
|
||||
|
||||
# dts云部署
|
||||
def yun_dep
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 软件知识库
|
||||
def soft_knowledge
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 在线开发平台
|
||||
def online_dev
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 软件资源库
|
||||
def soft_file
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
# 软件服务
|
||||
def soft_service
|
||||
render_403 unless User.current.admin?
|
||||
end
|
||||
|
||||
#发送邮件邀请新用户
|
||||
# 发送邮件邀请新用户页面对应方法
|
||||
def invite_members_by_mail
|
||||
if User.current.member_of?(@project) || User.current.admin?
|
||||
@inviter_lists = InviteList.where(project_id:@project.id).all
|
||||
@inviters = []
|
||||
@waiters = []
|
||||
unless @inviter_lists.blank?
|
||||
@inviter_lists.each do|inviter_list|
|
||||
unless inviter_list.user.nil?
|
||||
if inviter_list.user.member_of?(@project)
|
||||
@inviters << inviter_list.user
|
||||
@inviters_count = @inviters.size
|
||||
else
|
||||
@waiters << inviter_list.user
|
||||
@waiters_count = @waiters.size
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@inviter_lists = InviteList.where(project_id:@project.id).order("created_at desc")
|
||||
|
||||
# @inviters = []
|
||||
# @waiters = []
|
||||
# unless @inviter_lists.blank?
|
||||
# @inviter_lists.each do|inviter_list|
|
||||
# unless inviter_list.user.nil?
|
||||
# if inviter_list.user.member_of?(@project)
|
||||
# @inviters << inviter_list.user
|
||||
# @inviters_count = @inviters.size
|
||||
# else
|
||||
# @waiters << inviter_list.user
|
||||
# @waiters_count = @waiters.size
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
@is_zhuce = false
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
@ -430,16 +452,16 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
# 邀请Trustie注册用户
|
||||
def invite_members
|
||||
if User.current.member_of?(@project) || User.current.admin?
|
||||
@member ||= @project.members.new
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
# def invite_members
|
||||
# if User.current.member_of?(@project) || User.current.admin?
|
||||
# @member ||= @project.members.new
|
||||
# respond_to do |format|
|
||||
# format.html
|
||||
# end
|
||||
# else
|
||||
# render_403
|
||||
# end
|
||||
# end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
@ -447,6 +469,11 @@ class ProjectsController < ApplicationController
|
|||
# by young
|
||||
# include CoursesHelper
|
||||
def member
|
||||
# 消息"同意加入项目"
|
||||
if params[:message_id]
|
||||
message_invite(params[:message_id], params[:key])
|
||||
end
|
||||
update_message_status(User.current, @project)
|
||||
# params[:login]为邮箱邀请用户加入,主要功能:
|
||||
# 1、自动注册
|
||||
# 2、加入项目、创建角色
|
||||
|
@ -468,6 +495,10 @@ class ProjectsController < ApplicationController
|
|||
flash[:notice] = l(:label_mail_invite_success)
|
||||
end
|
||||
end
|
||||
# 私有项目非项目成员无法访问成员列表
|
||||
unless @project.is_public?
|
||||
return render_403 unless User.current.member_of?(@project)
|
||||
end
|
||||
## 有角色参数的才是课程,没有的就是项目
|
||||
@render_file = 'project_member_list'
|
||||
# 判断是否课程
|
||||
|
@ -498,6 +529,24 @@ class ProjectsController < ApplicationController
|
|||
@members = paginateHelper @members
|
||||
end
|
||||
|
||||
def update_message_status(user, project)
|
||||
project_invite_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =?", user, project, "ProjectInvite")
|
||||
project_invite_messages.each do |project_invite_message|
|
||||
project_invite_message.update_attribute(:viewed, true)
|
||||
end
|
||||
end
|
||||
|
||||
def message_invite(message_id, key)
|
||||
forge_message = ForgeMessage.find(message_id)
|
||||
if key == forge_message.secret_key
|
||||
# 情况:用户收到邀请邮件还没看,但是管理员已经把该用户添加进项目
|
||||
if Member.where("user_id =? and project_id =?",forge_message.user_id, forge_message.project_id).first.nil?
|
||||
Member.create(:role_ids => [4], :user_id => forge_message.user_id, :project_id => forge_message.project_id)
|
||||
UserGrade.create(:user_id => forge_message.user_id, :project_id => forge_message.project_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#判断指定用户是否为课程教师
|
||||
def isCourseTeacher(id)
|
||||
result = false
|
||||
|
@ -610,14 +659,10 @@ class ProjectsController < ApplicationController
|
|||
# Delete @project
|
||||
def destroy
|
||||
@project_to_destroy = @project
|
||||
if api_request? || params[:confirm]
|
||||
@project_to_destroy.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to admin_projects_url }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
render :layout => "base_projects"
|
||||
@project_to_destroy.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to admin_projects_url }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
# hide project in layout
|
||||
@project = nil
|
||||
|
|
|
@ -136,7 +136,7 @@ update
|
|||
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name
|
||||
attrs = pickup_extra_info
|
||||
if((@repository_tag!="")&¶ms[:repository_scm]=="Git")
|
||||
params[:repository][:url]=@project_path
|
||||
params[:repository][:url]=@project_path
|
||||
end
|
||||
###xianbo
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
|
|
|
@ -207,7 +207,7 @@ class SoftapplicationsController < ApplicationController
|
|||
@softapplication.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to home_url }
|
||||
format.html { redirect_to signin_path }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,16 +3,81 @@ class StudentWorkController < ApplicationController
|
|||
include StudentWorkHelper
|
||||
require 'bigdecimal'
|
||||
require "base64"
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule]
|
||||
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
|
||||
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
|
||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
||||
protect_from_forgery :except => :set_program_score
|
||||
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule]
|
||||
|
||||
###
|
||||
def program_test
|
||||
is_test = params[:is_test] == 'true'
|
||||
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
|
||||
|
||||
student_work = find_or_save_student_work(is_test)
|
||||
|
||||
unless student_work
|
||||
resultObj[:status] = 100
|
||||
else
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
||||
result = test_realtime(student_work, params[:src])
|
||||
logger.debug result
|
||||
resultObj[:status] = result["status"]
|
||||
resultObj[:results] = result["results"]
|
||||
resultObj[:error_msg] = result["error_msg"]
|
||||
results = result["results"]
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
results = [result["error_msg"]]
|
||||
end
|
||||
student_work_test = student_work.student_work_tests.build(status: result["status"], results: results,
|
||||
src: params[:src])
|
||||
unless student_work.save
|
||||
resultObj[:status] = 200
|
||||
else
|
||||
resultObj[:status] = result["status"].to_i
|
||||
resultObj[:time] = student_work_test.created_at.to_s(:db)
|
||||
resultObj[:index] = student_work.student_work_tests.count
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
render :json => resultObj
|
||||
end
|
||||
|
||||
def index
|
||||
# 作业消息状态更新
|
||||
@homework.course_messages.each do |homework_message|
|
||||
if User.current.id == homework_message.user_id && homework_message.viewed == 0
|
||||
homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0
|
||||
end
|
||||
end
|
||||
# 作品打分消息状态更新
|
||||
studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0)
|
||||
studentworks_scores.each do |studentworks_score|
|
||||
studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0
|
||||
end
|
||||
# 作品评论消息状态更新
|
||||
journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0)
|
||||
journals_for_teacher.each do |journal_for_teacher|
|
||||
journal_for_teacher.update_attributes(:viewed => true)
|
||||
end
|
||||
# 作品留言
|
||||
# 消息end
|
||||
#设置作业对应的forge_messages表的viewed字段
|
||||
query_student_work = @homework.course_messages
|
||||
query_student_work.each do |query|
|
||||
if User.current.id == query.user_id
|
||||
query.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
##################################################################################################################
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
|
||||
@show_all = false
|
||||
|
||||
course_group = CourseGroup.find_by_id(@group) if @group
|
||||
if course_group
|
||||
group_students = course_group.users
|
||||
|
@ -21,71 +86,51 @@ class StudentWorkController < ApplicationController
|
|||
else
|
||||
student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
|
||||
end
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
@show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
|
||||
@is_evaluation = true
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
if @is_teacher || @homework.homework_detail_manual.nil? #老师 || 超级管理员 显示所有列表
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
@show_all = true
|
||||
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
@show_all = true
|
||||
end
|
||||
else
|
||||
@stundet_works = []
|
||||
end
|
||||
else
|
||||
#老师 || 非匿评作业 || 匿评结束 显示所有的作品
|
||||
@show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
|
||||
if @show_all
|
||||
if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
if @order == "name"
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
end
|
||||
end
|
||||
else #学生
|
||||
if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
|
||||
@is_evaluation = true
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
if @is_teacher || @homework.homework_detail_manual.nil? #老师 || 超级管理员 显示所有列表
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
@show_all = true
|
||||
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
|
||||
my_work = @homework.student_works.where(:user_id => User.current.id)
|
||||
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
|
||||
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
|
||||
@show_all = true
|
||||
end
|
||||
else
|
||||
@stundet_works = []
|
||||
end
|
||||
end
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
format.xls {
|
||||
send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
|
@ -95,49 +140,48 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
student_work = @homework.student_works.where("user_id = ?",User.current.id).first
|
||||
if student_work.nil?
|
||||
@stundet_work = StudentWork.new
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
else
|
||||
render_403
|
||||
if @homework.homework_type==2
|
||||
redirect_to new_user_commit_homework_users_path(homework_id: @homework.id)
|
||||
return
|
||||
end
|
||||
@user = User.current
|
||||
@student_work = @homework.student_works.where("user_id = ?",User.current.id).first
|
||||
if @student_work.nil?
|
||||
@student_work = StudentWork.new
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{ render :layout => "new_base_user"}
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
if params[:student_work]
|
||||
stundet_work = StudentWork.new
|
||||
stundet_work.name = params[:student_work][:name]
|
||||
stundet_work.description = params[:student_work][:description]
|
||||
stundet_work.project_id = params[:student_work][:project_id]
|
||||
stundet_work.homework_common_id = @homework.id
|
||||
stundet_work.user_id = User.current.id
|
||||
stundet_work.save_attachments(params[:attachments])
|
||||
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
|
||||
student_work ||= StudentWork.new
|
||||
student_work.name = params[:student_work][:name]
|
||||
student_work.description = params[:student_work][:description]
|
||||
student_work.project_id = params[:student_work][:project_id]
|
||||
student_work.homework_common_id = @homework.id
|
||||
student_work.user_id = User.current.id
|
||||
student_work.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(student_work)
|
||||
#提交作品时,计算是否迟交
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
stundet_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
stundet_work.late_penalty = 0
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
student_work.late_penalty = 0
|
||||
end
|
||||
render_attachment_warning_if_needed(stundet_work)
|
||||
|
||||
if stundet_work.save
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
|
||||
url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
|
||||
solutions = {
|
||||
student_work_id:stundet_work.id,
|
||||
src:Base64.encode64(stundet_work.description),
|
||||
language:@homework.homework_detail_programing.language
|
||||
}
|
||||
uri = URI(url)
|
||||
body = solutions.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
if student_work.save
|
||||
course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first
|
||||
if course_activity
|
||||
course_activity.updated_at = Time.now
|
||||
course_activity.save
|
||||
end
|
||||
user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework.id}").first
|
||||
if user_activity
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
@ -157,11 +201,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@user = User.current
|
||||
if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业
|
||||
render_403
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.html{ render :layout => "new_base_user"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -190,16 +235,15 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
def show
|
||||
@score = student_work_score @work,User.current
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@student_work_scores = @work.student_works_scores.order("updated_at desc")
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @homework.homework_type == 2 #编程作业,作品提交后不可以删除
|
||||
render_403
|
||||
elsif @work.destroy
|
||||
if @work.destroy
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to student_work_index_url(:homework => @homework.id)
|
||||
|
@ -210,10 +254,11 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
#添加评分,已评分则为修改评分
|
||||
def add_score
|
||||
@is_last = params[:is_last] == "true"
|
||||
render_403 and return if User.current == @work.user #不可以匿评自己的作品
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
|
||||
render_403 and return unless @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2)
|
||||
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
|
||||
@score = student_work_score @work,User.current
|
||||
if @score
|
||||
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
|
@ -226,6 +271,7 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
@is_new = false
|
||||
else
|
||||
@is_last_a = @work.student_works_scores.empty?
|
||||
@score = StudentWorksScore.new
|
||||
@score.score = params[:score] if params[:score]
|
||||
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
|
@ -247,35 +293,11 @@ class StudentWorkController < ApplicationController
|
|||
case @score.reviewer_role
|
||||
when 1 #教师评分:最后一个教师评分为最终评分
|
||||
@work.teacher_score = @score.score
|
||||
@work.final_score = @score.score
|
||||
when 2 #教辅评分 教辅评分显示平均分
|
||||
@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
|
||||
if @work.teacher_score.nil?
|
||||
if @work.student_score.nil?
|
||||
@work.final_score = @work.teaching_asistant_score
|
||||
else
|
||||
ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual
|
||||
ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing
|
||||
final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
@work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
when 3 #学生评分 学生评分显示平均分
|
||||
@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
|
||||
if @work.teacher_score.nil?
|
||||
if @work.teaching_asistant_score.nil?
|
||||
@work.final_score = @work.student_score
|
||||
else
|
||||
final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
@work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if @work.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -287,6 +309,7 @@ class StudentWorkController < ApplicationController
|
|||
#添加评分的回复
|
||||
def add_score_reply
|
||||
@score = StudentWorksScore.find params[:score_id]
|
||||
@is_last = params[:is_last] == "true"
|
||||
@jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0)
|
||||
if @jour.save
|
||||
@status = 1
|
||||
|
@ -379,44 +402,53 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#设置编程作业得分
|
||||
def set_program_score
|
||||
stundet_work = StudentWork.find_by_id params[:student_work_id]
|
||||
@course = stundet_work.homework_common.course
|
||||
student_score_count = 0
|
||||
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
|
||||
homework_common = stundet_work.homework_common
|
||||
params[:results].each do |result|
|
||||
homework_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first
|
||||
if homework_test
|
||||
student_work_test = StudentWorkTest.new
|
||||
student_work_test.student_work = stundet_work
|
||||
student_work_test.homework_test = homework_test
|
||||
student_work_test.result = result[:status]
|
||||
if student_work_test.result == 0
|
||||
student_score_count += 1
|
||||
end
|
||||
student_work_test.error_msg = params[:compile_error_msg]
|
||||
student_work_test.save!
|
||||
#设置评分规则
|
||||
def set_score_rule
|
||||
homework_detail_manual = @homework.homework_detail_manual
|
||||
homework_detail_programing = @homework.homework_detail_programing
|
||||
|
||||
unless @homework.late_penalty.to_s == params[:late_penalty].to_s
|
||||
@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 = @homework.late_penalty
|
||||
student_work.save
|
||||
end
|
||||
|
||||
@homework.save
|
||||
end
|
||||
|
||||
unless homework_detail_manual.absence_penalty.to_s == params[:absence_penalty].to_s
|
||||
homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||
if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值
|
||||
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
|
||||
@homework.student_works.each do |student_work|
|
||||
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
|
||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
|
||||
student_work.save
|
||||
end
|
||||
end
|
||||
unless homework_common.homework_tests.empty?
|
||||
stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count
|
||||
|
||||
if stundet_work.teacher_score.nil?
|
||||
if stundet_work.teaching_asistant_score.nil?
|
||||
stundet_work.final_score = stundet_work.student_score
|
||||
else
|
||||
final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
stundet_work.final_score = format("%.1f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
end
|
||||
|
||||
stundet_work.save!
|
||||
teacher_priority = params[:teacher_priority] ? 1 : 0
|
||||
if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s)
|
||||
homework_detail_manual.ta_proportion = params[:ta_proportion]
|
||||
homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing
|
||||
@homework.teacher_priority = teacher_priority
|
||||
|
||||
@homework.save
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
homework_detail_programing.save if homework_detail_programing
|
||||
|
||||
@homework.student_works.each do |student_work|
|
||||
set_final_score @homework,student_work
|
||||
student_work.save
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{redirect_to student_work_index_url(:homework => @homework.id)}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -449,15 +481,19 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def teacher_of_course
|
||||
render_403 unless User.current.allowed_to?(:as_teacher,@course)
|
||||
render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
end
|
||||
|
||||
#根据条件过滤作业结果
|
||||
def search_homework_member homeworks,name
|
||||
name = name.downcase
|
||||
select_homework = homeworks.select{ |homework|
|
||||
homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name)
|
||||
}
|
||||
if name == ""
|
||||
select_homework = homeworks
|
||||
else
|
||||
name = name.downcase
|
||||
select_homework = homeworks.select{ |homework|
|
||||
homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name)
|
||||
}
|
||||
end
|
||||
select_homework
|
||||
end
|
||||
|
||||
|
@ -468,25 +504,7 @@ 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
|
||||
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 #匿评作业
|
||||
if @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
|
||||
|
@ -506,7 +524,7 @@ class StudentWorkController < ApplicationController
|
|||
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)])
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_s_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
|
||||
|
@ -517,9 +535,10 @@ class StudentWorkController < ApplicationController
|
|||
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)
|
||||
sheet1[count_row,8] = homework.system_score.nil? ? l(:label_without_score) : format("%.2f",homework.system_score)
|
||||
sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,11] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
|
@ -577,4 +596,145 @@ class StudentWorkController < ApplicationController
|
|||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
|
||||
def find_or_save_student_work(is_test)
|
||||
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
|
||||
if student_work.nil?
|
||||
@homework.student_works.build(
|
||||
name: params[:title],
|
||||
description: params[:src],
|
||||
user_id: User.current.id,
|
||||
is_test: is_test
|
||||
)
|
||||
unless @homework.save
|
||||
logger.debug @homework.errors.full_messages
|
||||
else
|
||||
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
|
||||
end
|
||||
end
|
||||
student_work
|
||||
end
|
||||
|
||||
|
||||
def test_realtime(student_work, src)
|
||||
url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
|
||||
|
||||
factor = []
|
||||
@homework.homework_tests.each do |test|
|
||||
factor << {input: test.input, output: test.output}
|
||||
end
|
||||
solutions = {
|
||||
src:src,
|
||||
language:@homework.homework_detail_programing.language,
|
||||
factor: factor
|
||||
}
|
||||
uri = URI(url)
|
||||
body = solutions.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
request = Net::HTTP::Post.new(uri.path)
|
||||
request.body = body
|
||||
request["Content-Type"] = "application/json"
|
||||
client.request(request)
|
||||
end
|
||||
JSON.parse(res.body)
|
||||
end
|
||||
|
||||
#成绩计算
|
||||
def set_final_score homework,student_work
|
||||
if homework && homework.homework_detail_manual
|
||||
if homework.homework_type == 1 #匿评作业
|
||||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
elsif student_work.student_score.nil?
|
||||
student_work.final_score = student_work.teaching_asistant_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_manual.ta_proportion
|
||||
final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
elsif student_work.student_score.nil?
|
||||
student_work.final_score = student_work.teaching_asistant_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_manual.ta_proportion
|
||||
final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
|
||||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
elsif student_work.student_score.nil? #学生未评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
else
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
elsif student_work.student_score.nil? #学生未评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
else
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,95 @@
|
|||
class SystemMessagesController < ApplicationController
|
||||
# before_filter :message_author, :only => [:show]
|
||||
#
|
||||
# def message_author
|
||||
# if(!User.current.logged? && !token.nil?)
|
||||
#
|
||||
# User.current =try_to_autologin1
|
||||
# end
|
||||
# if @system_messages
|
||||
# render_403 :message => :notice_not_authorized_message
|
||||
# else
|
||||
# deny_access
|
||||
# end
|
||||
# end
|
||||
|
||||
def index
|
||||
@system_messages = SystemMessage.all
|
||||
end
|
||||
|
||||
# def show
|
||||
# @system_messages = SystemMessage.find(params[:id])
|
||||
# end
|
||||
|
||||
# GET /products/new
|
||||
# def new
|
||||
# @product = Product.new
|
||||
# end
|
||||
|
||||
# GET /products/1/edit
|
||||
# def edit
|
||||
# end
|
||||
|
||||
# POST /products
|
||||
# POST /products.json
|
||||
def create
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
@system_messages = SystemMessage.new
|
||||
@system_messages.description = params[:system_message][:description]
|
||||
@system_messages.subject = params[:system_message][:subject]
|
||||
@system_messages.user_id = User.current.id
|
||||
respond_to do |format|
|
||||
if @system_messages.save
|
||||
format.html {redirect_to user_system_messages_path(User.current)}
|
||||
flash[:notice] = l(:notice_successful_message)
|
||||
else
|
||||
if params[:system_messages][:description].empty?
|
||||
flash[:error] = l(:label_content_blank_fail)
|
||||
else
|
||||
flash[:error] = l(:label_admin_message_fail)
|
||||
end
|
||||
format.html {redirect_to admin_messages_path}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /products/1
|
||||
# PATCH/PUT /products/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @product.update(product_params)
|
||||
# format.html { redirect_to @product, notice: 'Product was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @product }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @product.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# DELETE /products/1
|
||||
# DELETE /products/1.json
|
||||
# def destroy
|
||||
# @system_messages.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_product
|
||||
# @product = Product.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def message_params
|
||||
# params.require(:admin_system_messages).permit(:content)
|
||||
# end
|
||||
|
||||
|
||||
end
|
|
@ -15,6 +15,7 @@ class TagsController < ApplicationController
|
|||
include ContestsHelper
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
include TagsHelper
|
||||
include FilesHelper
|
||||
helper :projects
|
||||
helper :courses
|
||||
helper :tags
|
||||
|
@ -230,6 +231,103 @@ class TagsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#更新某个tag名称
|
||||
def update_tag_name
|
||||
@tag_name = params[:tagName]
|
||||
@rename_tag_name = params[:renameName]
|
||||
@taggable_id = params[:taggableId]
|
||||
@taggable_type = numbers_to_object_type(params[:taggableType])
|
||||
@course_id = params[:courseId]
|
||||
|
||||
@rename_tag = (ActsAsTaggableOn::Tag.find_by_name(@rename_tag_name)) #查找重命名后的tag
|
||||
@tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id #重命名前的tag_id
|
||||
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank?
|
||||
@obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank?
|
||||
if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。
|
||||
if @course_id
|
||||
course = Course.find @course_id
|
||||
if course
|
||||
course.attachments.each do |attachment|
|
||||
taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class)
|
||||
if taggings
|
||||
taggings.delete
|
||||
attachment.tag_list.add(@rename_tag_name.split(","))
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if(@rename_tag.nil?) #这次命名的是新的tag
|
||||
|
||||
# 是否还有其他记录 引用了 tag_id
|
||||
@tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}")
|
||||
# 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字
|
||||
if @tagging.count == 1
|
||||
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
|
||||
@tag.update_attributes({:name=>@rename_tag_name})
|
||||
else #如果tagging表中的记录大于1,那么就要新增tag记录
|
||||
|
||||
unless @obj.nil?
|
||||
@obj.tag_list.add(@rename_tag_name.split(","))
|
||||
@obj.save
|
||||
end
|
||||
#删除原来的对应的taggings的记录
|
||||
unless @taggings.nil?
|
||||
@taggings.delete
|
||||
end
|
||||
end
|
||||
else #这是已有的tag
|
||||
# 更改taggings记录里的tag_id
|
||||
unless @taggings.nil?
|
||||
@taggings.update_attributes({:tag_id=>@rename_tag.id})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@obj_flag = params[:taggableType]
|
||||
if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course)
|
||||
@course = @obj.container
|
||||
@tag_list = @tag_list = get_course_tag_list @course
|
||||
elsif @course_id
|
||||
@course = Course.find(@course_id)
|
||||
@tag_list = get_course_tag_list @course
|
||||
|
||||
#这里要引用FilesController里的逻辑了。将资源库当前的文件列表刷新一遍。
|
||||
@flag = params[:flag] || false
|
||||
sort = ""
|
||||
@sort = ""
|
||||
@order = ""
|
||||
@is_remote = false
|
||||
@isproject = false
|
||||
|
||||
sort = "#{Attachment.table_name}.created_on desc"
|
||||
|
||||
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
|
||||
|
||||
show_attachments @containers
|
||||
elsif @obj && @obj_flag == '5'
|
||||
@forum = @obj
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def show_attachments obj
|
||||
@attachments = []
|
||||
obj.each do |container|
|
||||
@attachments += container.attachments
|
||||
end
|
||||
@all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
|
||||
@limit = 10
|
||||
@feedback_count = @all_attachments.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||
@obj_attachments = paginateHelper @all_attachments,10
|
||||
end
|
||||
|
||||
def tag_save
|
||||
@select_tag_name = params[:tag_for_save][:tag_name]
|
||||
@tags = params[:tag_for_save][:name]
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,9 +22,26 @@ class WatchersController < ApplicationController
|
|||
def watch
|
||||
s = WatchesService.new
|
||||
watchables = s.watch params.merge(:current_user_id => User.current.id)
|
||||
if params[:action_name] == 'watch'
|
||||
limit = 10;
|
||||
query = User.watched_by(params[:target_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();
|
||||
@action = 'watch'
|
||||
elsif params[:action_name] == 'fans'
|
||||
limit = 10;
|
||||
query = User.find(params[:target_id]).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'
|
||||
else
|
||||
|
||||
end
|
||||
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,:params=>params,:opt=>'add'} }
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add',:list => @list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == "404"
|
||||
|
@ -38,9 +55,25 @@ class WatchersController < ApplicationController
|
|||
def unwatch
|
||||
s = WatchesService.new
|
||||
watchables = s.unwatch params.merge(:current_user_id => User.current.id)
|
||||
if params[:action_name] == 'watch'
|
||||
limit = 10;
|
||||
query = User.watched_by(params[:target_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();
|
||||
@action = 'watch'
|
||||
elsif params[:action_name] == 'fans'
|
||||
limit = 10;
|
||||
query = User.find(params[:target_id]).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'
|
||||
else
|
||||
end
|
||||
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,:params=>params,:opt=>'delete'} }
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete',:list=>@list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
|
||||
end
|
||||
rescue Exception => e
|
||||
if e.message == "404"
|
||||
|
|
|
@ -27,7 +27,8 @@ class WelcomeController < ApplicationController
|
|||
|
||||
def index
|
||||
# 企业版定制: params[:project]为传过来的参数
|
||||
|
||||
redirect_to signin_path
|
||||
return
|
||||
unless params[:organization].nil?
|
||||
@organization = Organization.find params[:organization]
|
||||
# @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all
|
||||
|
@ -97,9 +98,12 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
def course
|
||||
@course_page = FirstPage.find_by_page_type('course')
|
||||
@school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
|
||||
@logoLink ||= logolink()
|
||||
redirect_to signin_path
|
||||
return
|
||||
#
|
||||
# @course_page = FirstPage.find_by_page_type('course')
|
||||
# @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
|
||||
# @logoLink ||= logolink()
|
||||
end
|
||||
|
||||
def logolink()
|
||||
|
@ -139,8 +143,11 @@ class WelcomeController < ApplicationController
|
|||
|
||||
|
||||
def contest
|
||||
@contest_page = FirstPage.find_by_page_type('contest')
|
||||
@contest_notifications = Contestnotification.order("created_at desc").limit(5)
|
||||
redirect_to signin_path
|
||||
return
|
||||
|
||||
# @contest_page = FirstPage.find_by_page_type('contest')
|
||||
# @contest_notifications = Contestnotification.order("created_at desc").limit(5)
|
||||
end
|
||||
|
||||
def search
|
||||
|
@ -171,7 +178,7 @@ class WelcomeController < ApplicationController
|
|||
redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :student)
|
||||
else
|
||||
#redirect_to home_path, :alert => l(:label_sumbit_empty)
|
||||
(redirect_to home_url, :notice => l(:label_sumbit_empty);return) #if params[:name].blank?
|
||||
(redirect_to signin_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank?
|
||||
end
|
||||
}
|
||||
end
|
||||
|
@ -180,28 +187,28 @@ class WelcomeController < ApplicationController
|
|||
private
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
def entry_select
|
||||
url = request.original_url.gsub('/','')
|
||||
if url.include?(Setting.url_course.gsub('/',''))
|
||||
if @first_page.show_course == 1
|
||||
course
|
||||
render :course
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
||||
return 0
|
||||
elsif url.include?(Setting.url_contest.gsub('/',''))
|
||||
if @first_page.show_contest == 1
|
||||
contest
|
||||
render :contest
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
||||
return 0
|
||||
elsif url.include?(Setting.url_user.gsub('/',''))
|
||||
#redirect_to(:controller => "users", :action => "index")
|
||||
end
|
||||
# url = request.original_url.gsub('/','')
|
||||
# if url.include?(Setting.url_course.gsub('/',''))
|
||||
# if @first_page.show_course == 1
|
||||
# course
|
||||
# render :course
|
||||
# else
|
||||
# render_404
|
||||
# end
|
||||
#
|
||||
# return 0
|
||||
# elsif url.include?(Setting.url_contest.gsub('/',''))
|
||||
# if @first_page.show_contest == 1
|
||||
# contest
|
||||
# render :contest
|
||||
# else
|
||||
# render_404
|
||||
# end
|
||||
#
|
||||
# return 0
|
||||
# elsif url.include?(Setting.url_user.gsub('/',''))
|
||||
# #redirect_to(:controller => "users", :action => "index")
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -264,7 +264,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
@page.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to project_wiki_index_url(@project) }
|
||||
format.html {redirect_to edit_project_wiki_page_url @project, @page.title}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,19 @@ class WordsController < ApplicationController
|
|||
:notes => content,
|
||||
:is_readed => false}
|
||||
@jfm = add_reply_adapter options
|
||||
|
||||
@save_succ = true if @jfm.errors.empty?
|
||||
if @save_succ
|
||||
course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{parent_id}").first
|
||||
if course_activity
|
||||
course_activity.updated_at = Time.now
|
||||
course_activity.save
|
||||
end
|
||||
user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first
|
||||
if user_activity
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
# format.html {
|
||||
# if @jfm.errors.empty?
|
||||
|
@ -63,27 +75,31 @@ class WordsController < ApplicationController
|
|||
# end
|
||||
# render 'test/index'
|
||||
# }
|
||||
format.js{
|
||||
@save_succ = true if @jfm.errors.empty?
|
||||
format.js {
|
||||
@user_activity_id = params[:user_activity_id] if
|
||||
@activity = JournalsForMessage.find(parent_id)
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
|
||||
if @journal_destroyed.jour_type == "Bid"
|
||||
@bid = Bid.find(@journal_destroyed.jour_id)
|
||||
@jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
elsif @journal_destroyed.jour_type == "Course"
|
||||
@course = Course.find @journal_destroyed.jour_id
|
||||
@jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
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
|
||||
@journal_destroyed = JournalsForMessage.find params[:object_id]
|
||||
if @journal_destroyed.destroy
|
||||
if @journal_destroyed.jour_type == "Bid"
|
||||
@bid = Bid.find(@journal_destroyed.jour_id)
|
||||
@jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
elsif @journal_destroyed.jour_type == "Course"
|
||||
@course = Course.find @journal_destroyed.jour_id
|
||||
@jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -200,11 +216,15 @@ class WordsController < ApplicationController
|
|||
|
||||
#给用户留言
|
||||
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])
|
||||
if User.current.logged?
|
||||
@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)
|
||||
else
|
||||
render_403
|
||||
end
|
||||
redirect_to feedback_path(@user)
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'zip'
|
||||
require 'zip'
|
||||
class ZipdownController < ApplicationController
|
||||
#查找项目(课程)
|
||||
before_filter :find_project_by_bid_id, :only => [:assort]
|
||||
|
|
|
@ -75,7 +75,7 @@ module ApiHelper
|
|||
# 学生获取课程作业的状态
|
||||
def get_homework_status homework
|
||||
homework_status = ""
|
||||
if !homework.nil?
|
||||
if homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
|
|
|
@ -760,7 +760,8 @@ module ApplicationHelper
|
|||
options = args.extract_options!
|
||||
text = distance_of_time_in_words(Time.now, time)
|
||||
if @project
|
||||
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)},options.reverse_merge(:title => format_time(time)))
|
||||
content_tag('acronym', text, options.reverse_merge(:title => format_time(time)))
|
||||
# link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)},options.reverse_merge(:title => format_time(time)))
|
||||
else
|
||||
content_tag('acronym', text, options.reverse_merge(:title => format_time(time)))
|
||||
end
|
||||
|
@ -1812,7 +1813,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
|
||||
|
@ -1852,7 +1853,8 @@ module ApplicationHelper
|
|||
candown = true
|
||||
elsif attachment.container.class.to_s=="StudentWork"
|
||||
candown = true
|
||||
|
||||
elsif attachment.container.class.to_s == "User"
|
||||
candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id)
|
||||
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)
|
||||
|
@ -2253,6 +2255,21 @@ module ApplicationHelper
|
|||
technical_title
|
||||
end
|
||||
|
||||
def get_user_roll user
|
||||
technical_title = ""
|
||||
case user.user_extensions.identity.to_s
|
||||
when "0"
|
||||
technical_title = get_technical_title user
|
||||
when "1"
|
||||
technical_title = l(:label_account_identity_student)
|
||||
when "2"
|
||||
technical_title = l(:label_account_identity_enterprise)
|
||||
when "3"
|
||||
technical_title = l(:label_account_identity_developer)
|
||||
end
|
||||
technical_title
|
||||
end
|
||||
|
||||
|
||||
def ie8?
|
||||
request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/
|
||||
|
@ -2280,25 +2297,19 @@ module ApplicationHelper
|
|||
|
||||
#获取匿评相关连接代码
|
||||
def homework_anonymous_comment homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
link = "<span class='fr mr10 pr_join_span ' title='作业截止日期之前不可以启动匿评'>启动匿评</span>".html_safe
|
||||
elsif homework.student_works.count >= 2 #作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit'
|
||||
when 2
|
||||
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit'
|
||||
when 3
|
||||
link = "<span class='fr pr_join_span mr10' title='匿评结束'>匿评结束</span>".html_safe
|
||||
end
|
||||
else
|
||||
link = "<span class='fr mr10 pr_join_span ' title='学生提交作业数大于2时才可以启动匿评'>启动匿评</span>".html_safe
|
||||
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评"
|
||||
elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink'
|
||||
when 2
|
||||
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink'
|
||||
when 3
|
||||
# link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
|
||||
end
|
||||
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业
|
||||
link = "<span class='fr mr10 pr_join_span ' title='编程作业'>编程作业</span>".html_safe
|
||||
else
|
||||
link = "<span class='fr mr10 pr_join_span ' title='未开启匿评作业不可以启动匿评'>启动匿评</span>".html_safe
|
||||
link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "学生提交作业数大于等于2时才可以启动匿评"
|
||||
end
|
||||
link
|
||||
end
|
||||
|
@ -2306,20 +2317,58 @@ module ApplicationHelper
|
|||
def student_new_homework homework
|
||||
work = cur_user_works_for_homework homework
|
||||
if work.nil?
|
||||
link_to l(:label_commit_homework), new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit'
|
||||
link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit'
|
||||
else
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
|
||||
"<span class='fr mr10 pr_join_span '>#{l(:label_edit_homework)}</span>".html_safe
|
||||
elsif homework.homework_type == 2 #编程作业不能修改作品
|
||||
"<span class='fr mr10 pr_join_span ' title='编程作业不可修改作品'>作品已交</span>".html_safe
|
||||
link_to "作品已交", "javascript:void(0);", :class => 'fr mr10 pr_join_span c_white', :title => "开启匿评后不可修改作品"
|
||||
elsif homework.homework_type == 2 #编程作业修改作品
|
||||
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1
|
||||
link_to "作品已交", "javascript:void(0);", :class => 'fr mr10 pr_join_span c_white', :title => "开启匿评后不可修改作品"
|
||||
else
|
||||
link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit'
|
||||
end
|
||||
else
|
||||
link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit'
|
||||
link_to "修改作品", edit_student_work_path(work.id),:class => 'fr mr10 work_edit'
|
||||
end
|
||||
end
|
||||
end
|
||||
#动态列表中,确定学生是该提交还是进列表
|
||||
def student_work_activity_submit_status(opt={})
|
||||
default_opt = {class: 'c_blue'}.merge(opt)
|
||||
|
||||
is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
|
||||
|
||||
homework = default_opt[:homework]
|
||||
work = cur_user_works_for_homework homework
|
||||
if work.nil? && !is_teacher
|
||||
link_to "提交("+homework.student_works.count.to_s+")", new_student_work_path(:homework => homework.id,:host=> Setting.host_course), :class=> default_opt[:class]
|
||||
else
|
||||
link_to "提交("+homework.student_works.count.to_s+")", student_work_index_path(:homework => homework.id,:host=> Setting.host_course), :class=> default_opt[:class]
|
||||
end
|
||||
end
|
||||
|
||||
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
|
||||
def user_for_homework_common homework,is_teacher
|
||||
if is_teacher #老师显示作品数量
|
||||
link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue"
|
||||
else #学生显示提交作品、修改作品等按钮
|
||||
work = cur_user_works_for_homework homework
|
||||
if work.nil?
|
||||
link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue'
|
||||
else
|
||||
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前
|
||||
link_to "作品已交", "javascript:void(0)", :class => 'c_blue', :title => "开启匿评后不可修改作品"
|
||||
elsif homework.homework_type == 2 #编程作业不能修改作品
|
||||
link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'c_blue'
|
||||
else
|
||||
link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def student_anonymous_comment homework
|
||||
if homework.homework_type == 1 && homework.homework_detail_manual
|
||||
if homework.homework_detail_manual
|
||||
case homework.homework_detail_manual.comment_status
|
||||
when 1
|
||||
"<span class='fr mr10 pr_join_span '>未开启匿评</span>".html_safe
|
||||
|
@ -2328,10 +2377,6 @@ module ApplicationHelper
|
|||
when 3
|
||||
"<span class='fr mr10 pr_join_span '>匿评已结束</span>".html_safe
|
||||
end
|
||||
elsif homework.homework_type == 0
|
||||
"<span class='fr mr10 pr_join_span '>未启用匿评</span>".html_safe
|
||||
elsif homework.homework_type == 2
|
||||
"<span class='fr mr10 pr_join_span '> 编程作业 </span>".html_safe
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2378,4 +2423,108 @@ module ApplicationHelper
|
|||
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
|
||||
|
||||
#判断用户是否已经提交了问卷
|
||||
def has_commit_poll?(poll_id,user_id)
|
||||
pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id)
|
||||
if pu.nil?
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# encoding: utf-8
|
||||
include UsersHelper
|
||||
module HomeworkCommonHelper
|
||||
#迟交扣分下拉框
|
||||
def late_penalty_option
|
||||
|
@ -66,4 +67,31 @@ module HomeworkCommonHelper
|
|||
link
|
||||
end
|
||||
|
||||
#将状态转换为错误信息
|
||||
def status_to_err_msg status
|
||||
case status.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
'输入和输出不匹配'
|
||||
when -3
|
||||
'输入和输出不匹配'
|
||||
when 1
|
||||
'运行出错'
|
||||
when 2
|
||||
'超时'
|
||||
when 3
|
||||
'内存超出'
|
||||
when 4
|
||||
'输出超出'
|
||||
when 5
|
||||
'禁用函数'
|
||||
when 6
|
||||
'其他错误'
|
||||
when 0
|
||||
'成功'
|
||||
else
|
||||
'未知错误'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -380,6 +380,22 @@ module IssuesHelper
|
|||
value = content_tag("i", h(value)) if value
|
||||
end
|
||||
end
|
||||
# 缺陷更新结果在消息中显示样式
|
||||
if no_html == "message"
|
||||
label = content_tag(:span, label, :class => "issue_update_message")
|
||||
old_value = content_tag("span", h(old_value)) if detail.old_value
|
||||
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
||||
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
||||
# Link to the attachment if it has not been removed
|
||||
if options[:token].nil?
|
||||
value = atta.filename
|
||||
else
|
||||
value = atta.filename
|
||||
end
|
||||
else
|
||||
value = content_tag(:span, h(value), :class => "issue_update_message_value") if value
|
||||
end
|
||||
end
|
||||
|
||||
if detail.property == 'attr' && detail.prop_key == 'description'
|
||||
s = l(:text_journal_changed_no_detail, :label => label)
|
||||
|
|
|
@ -116,10 +116,10 @@ module JournalsHelper
|
|||
end
|
||||
end
|
||||
#content << content_tag('div', links.join(' ').html_safe, :class => 'contextual', :style => 'margin-top:-25px;') unless links.empty?
|
||||
content << textilizable(journal, :notes)
|
||||
content << textAreailizable(journal, :notes)
|
||||
css_classes = "wiki"
|
||||
css_classes << " editable" if editable
|
||||
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:510px")
|
||||
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||
end
|
||||
|
||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||
|
|
|
@ -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
|
|
@ -18,6 +18,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
include AvatarHelper
|
||||
include StudentWorkHelper
|
||||
module ProjectsHelper
|
||||
def link_to_version(version, options = {})
|
||||
return '' unless version && version.is_a?(Version)
|
||||
|
@ -75,6 +76,47 @@ module ProjectsHelper
|
|||
return result
|
||||
end
|
||||
|
||||
# 项目类型
|
||||
def project_type_select
|
||||
type = []
|
||||
option1 = []
|
||||
option1 << l(:label_development_team)
|
||||
option1 << l(:label_development_team)
|
||||
option2 = []
|
||||
option2 << l(:label_research_group)
|
||||
option2 << l(:label_research_group)
|
||||
option3 = []
|
||||
option3 << l(:label_friend_organization)
|
||||
option3 << l(:label_friend_organization)
|
||||
type << option1
|
||||
type << option2
|
||||
type << option3
|
||||
type
|
||||
end
|
||||
|
||||
# 项目类型描述
|
||||
def project_newtype_descrption
|
||||
case params
|
||||
when 1
|
||||
value = l(:label_type_des_development)
|
||||
when 2
|
||||
value = l(:label_type_des_research)
|
||||
when 3
|
||||
value = l(:label_type_des_friend)
|
||||
end
|
||||
end
|
||||
|
||||
# 被邀请成员的状态
|
||||
def status_for_ivitied(ivite_list, project)
|
||||
if ivite_list.user.member_of?(project)
|
||||
value = "已经加入了项目!"
|
||||
elsif ivite_list.user.active?
|
||||
value = "邀请已发送,等待用户加入!"
|
||||
else
|
||||
value = "邀请已发送,等待用户激活账号!"
|
||||
end
|
||||
end
|
||||
|
||||
# Added by young
|
||||
def course_settings_tabs
|
||||
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'},
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
module RepositoriesHelper
|
||||
if Rails.env.development?
|
||||
ROOT_PATH="/tmp/" if Rails.env.development?
|
||||
ROOT_PATH="/private/tmp/"
|
||||
else
|
||||
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
|
||||
end
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
# encoding: utf-8
|
||||
include UserScoreHelper
|
||||
|
||||
module StudentWorkHelper
|
||||
#获取当前用户的项目列表
|
||||
def user_projects_option
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
memberships = User.current.memberships.all(:conditions => cond)
|
||||
projects = memberships.map(&:project)
|
||||
projects = User.current.projects.visible
|
||||
not_have_project = []
|
||||
not_have_project << Setting.please_chose
|
||||
not_have_project << "请选择关联项目"
|
||||
not_have_project << 0
|
||||
type = []
|
||||
type << not_have_project
|
||||
projects.each do |project|
|
||||
if project != nil
|
||||
if project
|
||||
option = []
|
||||
option << project.name
|
||||
option << project.id
|
||||
|
@ -98,4 +99,31 @@ module StudentWorkHelper
|
|||
end
|
||||
result
|
||||
end
|
||||
|
||||
#教辅评分比例下拉框
|
||||
def ta_proportion_option
|
||||
type = []
|
||||
i = 0
|
||||
while i <= 100
|
||||
option = []
|
||||
option << i.to_s + "%"
|
||||
option << i.to_f / 100
|
||||
type << option
|
||||
i += 10
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
def ta_proportion_option_to num
|
||||
type = []
|
||||
i = 0
|
||||
while i <= num
|
||||
option = []
|
||||
option << i.to_s + "%"
|
||||
option << i.to_f / 100
|
||||
type << option
|
||||
i += 10
|
||||
end
|
||||
type
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module SystemMessagesHelper
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
module TagsHelper
|
||||
include StoresHelper
|
||||
include CoursesHelper
|
||||
# 通过 id和type获取对象
|
||||
def get_object(obj_id,obj_type)
|
||||
@obj = nil
|
||||
|
@ -62,6 +63,27 @@ module TagsHelper
|
|||
|
||||
end
|
||||
|
||||
#判断课程course中是否包含课件attachment,course中引用了attachment也算作包含
|
||||
def course_contains_attachment? course,attachment
|
||||
course.attachments.each do |att|
|
||||
if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
#判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期
|
||||
def has_course? user,file
|
||||
result = false
|
||||
user.courses.each do |course|
|
||||
if !course_contains_attachment?(course,file) && is_course_teacher(User.current,course) && course_in_current_or_next_term(course)
|
||||
return true
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
# 判断用户是否是贴吧的管理员
|
||||
# add by chenmin
|
||||
def is_forum_manager?(user_id,forum_id)
|
||||
|
|
|
@ -423,7 +423,7 @@ module UserScoreHelper
|
|||
|
||||
#更新分数
|
||||
def update_score(option_number)
|
||||
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number)
|
||||
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + project_active(option_number)
|
||||
if option_number.total_score < 0
|
||||
option_number.total_score = 0
|
||||
end
|
||||
|
@ -433,7 +433,7 @@ module UserScoreHelper
|
|||
|
||||
#协同得分
|
||||
def collaboration(option_number)
|
||||
option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo
|
||||
option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo
|
||||
end
|
||||
#影响力得分
|
||||
def influence(option_number)
|
||||
|
@ -444,8 +444,8 @@ module UserScoreHelper
|
|||
option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6
|
||||
end
|
||||
#项目贡献得分
|
||||
def active(option_number)
|
||||
option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2
|
||||
def project_active(option_number)
|
||||
option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4
|
||||
end
|
||||
|
||||
#更新发帖数
|
||||
|
|
|
@ -29,6 +29,63 @@ module UsersHelper
|
|||
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
|
||||
end
|
||||
|
||||
def get_resource_type type
|
||||
case type
|
||||
when 'Course'
|
||||
'课程资源'
|
||||
when 'Project'
|
||||
'项目资源'
|
||||
when 'Issue'
|
||||
'缺陷附件'
|
||||
when 'Message'
|
||||
'讨论区附件'
|
||||
when 'Document'
|
||||
'文档附件'
|
||||
when 'News'
|
||||
'通知附件'
|
||||
when 'HomewCommon'
|
||||
'作业附件'
|
||||
when 'StudentWorkScore'
|
||||
'批改附件'
|
||||
when 'Principal'
|
||||
'用户资源'
|
||||
end
|
||||
end
|
||||
|
||||
def title_for_message type
|
||||
case type
|
||||
when nil
|
||||
'消息'
|
||||
when 'unviewed'
|
||||
'未读消息'
|
||||
when 'apply'
|
||||
'用户申请'
|
||||
when 'system_messages'
|
||||
'系统消息'
|
||||
when 'homework'
|
||||
'作业消息'
|
||||
when 'course_message'
|
||||
'课程讨论'
|
||||
when 'course_news'
|
||||
'课程通知'
|
||||
when 'issue'
|
||||
'项目任务'
|
||||
when 'forum'
|
||||
'贴吧帖子'
|
||||
when 'user_feedback'
|
||||
'用户留言'
|
||||
end
|
||||
end
|
||||
|
||||
# 统计未读消息数
|
||||
def unviewed_message(user)
|
||||
course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
messages_count = course_count + forge_count + user_feedback_count + user_memo_count
|
||||
end
|
||||
|
||||
def user_mail_notification_options(user)
|
||||
user.valid_notification_options.collect {|o| [l(o.last), o.first]}
|
||||
end
|
||||
|
@ -48,7 +105,7 @@ module UsersHelper
|
|||
def user_settings_tabs
|
||||
tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
|
||||
{:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
|
||||
]
|
||||
]
|
||||
if Group.all.any?
|
||||
tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural}
|
||||
end
|
||||
|
@ -96,14 +153,14 @@ module UsersHelper
|
|||
def watch_projects(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
s = content_tag('span', l(:label_project_take), :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
|
||||
when 1
|
||||
s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
|
||||
content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
when 0
|
||||
s = content_tag('span', l(:label_project_take), :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
|
||||
when 1
|
||||
s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
|
||||
content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
end
|
||||
content_tag('div', content, :class => "pagination")
|
||||
end
|
||||
|
@ -113,57 +170,57 @@ module UsersHelper
|
|||
if @user != User.current
|
||||
if @user.user_extensions.identity == 0
|
||||
case state
|
||||
when 0
|
||||
s = content_tag('span', '他执教的课程', :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', '他发布的作业', :class => "current-page")
|
||||
content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 0
|
||||
s = content_tag('span', '他执教的课程', :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', '他发布的作业', :class => "current-page")
|
||||
content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
end
|
||||
else
|
||||
case state
|
||||
when 0
|
||||
s = content_tag('span', '他的课程', :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', '他的作业', :class => "current-page")
|
||||
content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 0
|
||||
s = content_tag('span', '他的课程', :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', '他的作业', :class => "current-page")
|
||||
content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
end
|
||||
end
|
||||
else
|
||||
if @user.user_extensions.identity == 0
|
||||
case state
|
||||
when 0
|
||||
s = content_tag('span', l(:label_teaching_course), :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', l(:label_release_homework), :class => "current-page")
|
||||
content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 0
|
||||
s = content_tag('span', l(:label_teaching_course), :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', l(:label_release_homework), :class => "current-page")
|
||||
content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
end
|
||||
else
|
||||
case state
|
||||
when 0
|
||||
s = content_tag('span', l(:label_my_course), :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', '我的作业', :class => "current-page")
|
||||
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 0
|
||||
s = content_tag('span', l(:label_my_course), :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
|
||||
content_tag('div', content, :class => "pagination")
|
||||
when 1
|
||||
s = content_tag('span', '我的作业', :class => "current-page")
|
||||
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content_tag('div', content, :class => "pagination")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -173,18 +230,18 @@ module UsersHelper
|
|||
def sort_user(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
|
||||
when 2
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
|
||||
when 2
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
|
@ -193,18 +250,18 @@ module UsersHelper
|
|||
def sort_user_enterprise(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
|
||||
when 2
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
|
||||
when 2
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs_enterprise")
|
||||
|
@ -267,7 +324,7 @@ module UsersHelper
|
|||
membership.collect { |e|
|
||||
memberships.push(e)
|
||||
}
|
||||
## 判断课程是否过期 [需封装]
|
||||
## 判断课程是否过期 [需封装]
|
||||
memberships_doing = []
|
||||
memberships_done = []
|
||||
memberships.map { |e|
|
||||
|
@ -321,6 +378,7 @@ module UsersHelper
|
|||
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
|
||||
|
@ -332,33 +390,45 @@ module UsersHelper
|
|||
end
|
||||
|
||||
def get_create_course_count(user)
|
||||
if user == User.current
|
||||
user.courses.count
|
||||
else
|
||||
user.courses.where("is_public = 1").count
|
||||
end
|
||||
user.courses.visible.where("tea_id = ?",user.id).count
|
||||
end
|
||||
|
||||
#获取加入课程数
|
||||
def get_join_course_count(user)
|
||||
user.coursememberships.count - get_create_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)
|
||||
Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count
|
||||
user.projects.visible.where("projects.user_id=#{user.id}").count
|
||||
end
|
||||
|
||||
#加入项目数
|
||||
def get_join_project_count(user)
|
||||
user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_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
|
||||
|
@ -388,6 +458,19 @@ module UsersHelper
|
|||
end
|
||||
return str.html_safe
|
||||
end
|
||||
|
||||
# journal.details 记录每个动作的新旧值
|
||||
def get_issue_des_update(journal)
|
||||
no_html = "message"
|
||||
arr = details_to_strings(journal.details, no_html)
|
||||
unless journal.notes.blank?
|
||||
arr << journal.notes
|
||||
end
|
||||
str = ''
|
||||
arr.each { |item| str = str+item }
|
||||
return str
|
||||
end
|
||||
|
||||
def get_activity_act_showname(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
|
@ -418,6 +501,7 @@ module UsersHelper
|
|||
return activity.act_type
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_act_createtime(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
|
@ -428,6 +512,7 @@ module UsersHelper
|
|||
return activity.act.created_on
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_container_url e
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
|
@ -438,6 +523,7 @@ module UsersHelper
|
|||
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:;"
|
||||
|
@ -466,6 +552,7 @@ module UsersHelper
|
|||
return 'javascript:;'
|
||||
end
|
||||
end
|
||||
|
||||
def get_activity_opt(activity,e)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
|
@ -488,4 +575,20 @@ module UsersHelper
|
|||
end
|
||||
end
|
||||
|
||||
#获取指定用户作为老师的课程
|
||||
def get_as_teacher_courses user
|
||||
type = []
|
||||
option = []
|
||||
option << "请选择发布作业的课程"
|
||||
option << -1
|
||||
type << option
|
||||
user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
|
||||
option = []
|
||||
option << course.name+"("+course.time.to_s+course.term+")"
|
||||
option << course.id
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,8 +1,21 @@
|
|||
class AppliedProject < ActiveRecord::Base
|
||||
attr_accessible :project_id, :user_id
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
|
||||
after_create :send_appliled_message
|
||||
|
||||
def send_appliled_message
|
||||
# if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.project.members.each do |m|
|
||||
if m.roles.first.to_s.include?("Manager")
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
#删除用户申请
|
||||
def self.deleteappiled(userid, projectid)
|
||||
|
@ -11,5 +24,4 @@ class AppliedProject < ActiveRecord::Base
|
|||
applied.destroy
|
||||
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
|
||||
|
|
|
@ -21,6 +21,10 @@ class Comment < ActiveRecord::Base
|
|||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
# 课程/项目 消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
#end
|
||||
acts_as_event :datetime => :updated_on,
|
||||
:description => :comments,
|
||||
:type => 'news',
|
||||
|
@ -31,7 +35,19 @@ class Comment < ActiveRecord::Base
|
|||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :comments
|
||||
safe_attributes 'comments'
|
||||
after_create :send_mail
|
||||
after_create :send_mail, :act_as_system_message
|
||||
|
||||
def act_as_system_message
|
||||
if self.commented.course
|
||||
if self.author_id != self.commented.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false)
|
||||
end
|
||||
else # 项目相关
|
||||
if self.author_id != self.commented.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def send_mail
|
||||
if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
|
||||
|
|
|
@ -33,6 +33,12 @@ 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, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
|
@ -44,7 +50,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 +316,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,37 @@
|
|||
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
|
||||
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
||||
after_save :add_user_activity
|
||||
before_destroy :destroy_user_activity
|
||||
|
||||
#在个人动态里面增加当前动态
|
||||
def add_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'").first
|
||||
if user_activity
|
||||
user_activity.save
|
||||
else
|
||||
if self.course_act_type == 'Message' && !self.course_act.parent_id.nil?
|
||||
user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.course_act.parent.id}").first
|
||||
user_activity.created_at = self.created_at
|
||||
user_activity.save
|
||||
else
|
||||
user_activity = UserActivity.new
|
||||
user_activity.act_id = self.course_act_id
|
||||
user_activity.act_type = self.course_act_type
|
||||
user_activity.container_type = "Course"
|
||||
user_activity.container_id = self.course_id
|
||||
user_activity.user_id = self.user_id
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'")
|
||||
user_activity.destroy_all
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
# status说明: status在课程不同的类型,区分不同的功能
|
||||
# HomeworkCommon:status:
|
||||
# nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status
|
||||
|
||||
# 多态 虚拟关联
|
||||
belongs_to :course_message ,:polymorphic => true
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
|
||||
validates :user_id,presence: true
|
||||
validates :course_id,presence: true
|
||||
validates :course_message_id,presence: true
|
||||
validates :course_message_type, presence: true
|
||||
validates_length_of :content, :maximum => 100
|
||||
after_create :add_user_message
|
||||
|
||||
def add_user_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -19,5 +19,34 @@ class ForgeActivity < ActiveRecord::Base
|
|||
validates :project_id,presence: true
|
||||
validates :forge_act_id,presence: true
|
||||
validates :forge_act_type, presence: true
|
||||
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
||||
after_save :add_user_activity
|
||||
before_destroy :destroy_user_activity
|
||||
|
||||
#在个人动态里面增加当前动态
|
||||
def add_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'").first
|
||||
if user_activity
|
||||
user_activity.save
|
||||
else
|
||||
if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil?
|
||||
user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.forge_act.parent.id}").first
|
||||
user_activity.created_at = self.created_at
|
||||
user_activity.save
|
||||
else
|
||||
user_activity = UserActivity.new
|
||||
user_activity.act_id = self.forge_act_id
|
||||
user_activity.act_type = self.forge_act_type
|
||||
user_activity.container_type = "Project"
|
||||
user_activity.container_id = self.project_id
|
||||
user_activity.user_id = self.user_id
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'")
|
||||
user_activity.destroy_all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
class ForgeMessage < ActiveRecord::Base
|
||||
# status在不同的类中,作用不同
|
||||
# Isseu: satus nil:发布了缺陷;:1:缺陷计划完成日志到了提醒
|
||||
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key, :status
|
||||
|
||||
belongs_to :forge_message ,:polymorphic => true
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
|
||||
validates :user_id,presence: true
|
||||
validates :project_id,presence: true
|
||||
validates :forge_message_id,presence: true
|
||||
validates :forge_message_type, presence: true
|
||||
after_create :add_user_message
|
||||
|
||||
def add_user_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@ class Forum < ActiveRecord::Base
|
|||
'sticky',
|
||||
'locked'
|
||||
validates_presence_of :name, :creator_id, :description
|
||||
validates_length_of :name, maximum: 50
|
||||
validates_length_of :name, maximum: 160
|
||||
#validates_length_of :description, maximum: 255
|
||||
validates :name, :uniqueness => true
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
@ -39,6 +39,7 @@ class Forum < ActiveRecord::Base
|
|||
logger.debug "send mail for forum add."
|
||||
Mailer.run.forum_add(self) if Setting.notified_events.include?('forum_add')
|
||||
end
|
||||
|
||||
# Updates topic_count, memo_count and last_memo_id attributes for +board_id+
|
||||
def self.reset_counters!(forum_id)
|
||||
forum_id = forum_id.to_i
|
||||
|
|
|
@ -10,20 +10,43 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
has_one :homework_detail_manual, :dependent => :destroy
|
||||
has_one :homework_detail_programing, :dependent => :destroy
|
||||
has_many :homework_tests, :dependent => :destroy
|
||||
has_many :student_works, :dependent => :destroy
|
||||
has_many :student_works, :dependent => :destroy, :conditions => "is_test=0"
|
||||
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
|
||||
|
@ -33,4 +56,10 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
Mailer.run.homework_added(self)
|
||||
end
|
||||
|
||||
def is_program_homework?
|
||||
self.homework_type == 2 && self.homework_detail_programing
|
||||
end
|
||||
|
||||
delegate :language_name, :language, :to => :homework_detail_programing
|
||||
|
||||
end
|
||||
|
|
|
@ -2,4 +2,8 @@ class HomeworkDetailPrograming < ActiveRecord::Base
|
|||
attr_accessible :language, :standard_code, :homework_common_id
|
||||
|
||||
belongs_to :homework_common
|
||||
|
||||
def language_name
|
||||
%W(C C++ Python Java).at(self.language.to_i - 1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class HomeworkTest < ActiveRecord::Base
|
||||
attr_accessible :input, :output, :homework_common_id
|
||||
attr_accessible :input, :output, :homework_common_id,:result,:error_msg
|
||||
|
||||
belongs_to :homework_common
|
||||
has_many :student_work_test
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class InviteList < ActiveRecord::Base
|
||||
attr_accessible :project_id, :user_id
|
||||
attr_accessible :project_id, :user_id, :mail
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -139,6 +141,28 @@ class Issue < ActiveRecord::Base
|
|||
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
|
||||
if self.tracker_id == 5
|
||||
self.project.members.each do |m|
|
||||
if m.roles.first.to_s.include?("Manager") && m.user_id != self.author_id && m.user_id != self.assigned_to_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 更新缺陷
|
||||
#def act_as_forge_message_update
|
||||
# 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
|
||||
def self.visible_condition(user, options={})
|
||||
|
@ -235,9 +259,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
|
||||
|
@ -1374,6 +1399,7 @@ class Issue < ActiveRecord::Base
|
|||
def attachment_added(obj)
|
||||
if @current_journal && @current_journal.user_id == obj.author_id && JournalDetail.find_all_by_value(obj.filename).count == 0
|
||||
@current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1382,6 +1408,9 @@ class Issue < ActiveRecord::Base
|
|||
if @current_journal && !obj.new_record?
|
||||
@current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
|
||||
@current_journal.save
|
||||
user_activity = UserActivity.where("act_type='Issue' and act_id =#{@current_journal.journalized_id}").first
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1488,6 +1517,9 @@ class Issue < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
@current_journal.save
|
||||
user_activity = UserActivity.where("act_type='Issue' and act_id =#{@current_journal.journalized_id}").first
|
||||
user_activity.updated_at = Time.now
|
||||
user_activity.save
|
||||
# reset current journal
|
||||
init_journal @current_journal.user, @current_journal.notes
|
||||
end
|
||||
|
|
|
@ -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,25 @@ 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
|
||||
receivers = []
|
||||
# 直接回复
|
||||
if self.user_id != self.issue.author_id
|
||||
receivers << self.issue.author_id
|
||||
end
|
||||
if self.user_id != self.issue.assigned_to_id && self.issue.assigned_to_id != self.issue.author_id # 指派人不是自己的话,则给指派人发送
|
||||
receivers << self.issue.assigned_to_id
|
||||
end
|
||||
receivers.each do |r|
|
||||
self.forge_messages << ForgeMessage.new(:user_id => r, :project_id => self.issue.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
|
||||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
|
|
|
@ -5,8 +5,34 @@ class JournalReply < ActiveRecord::Base
|
|||
|
||||
belongs_to :user
|
||||
belongs_to :journal
|
||||
after_create :send_journal_messages
|
||||
|
||||
def self.add_reply(journal_id, reply_id, user_id)
|
||||
self.create(:journal_id => journal_id, :reply_id => reply_id, :user_id => user_id)
|
||||
end
|
||||
|
||||
def send_journal_messages
|
||||
journal = self.journal
|
||||
replier = User.find(self.reply_id)
|
||||
receivers = []
|
||||
# 被回复的人发送消息
|
||||
if journal.user_id != self.reply_id && self.reply_id != journal.issue.author_id && self.reply_id != journal.issue.assigned_to_id
|
||||
receivers << replier
|
||||
end
|
||||
if journal.user_id != journal.issue.author_id && self.reply_id != journal.issue.author_id
|
||||
receivers << self.journal.issue.author
|
||||
end
|
||||
# journal_forge_messages = ForgeMessage.new
|
||||
receivers.each do |r|
|
||||
journal.forge_messages << ForgeMessage.new(:user_id =>r.id, :project_id => journal.issue.project_id, :viewed => false)
|
||||
end
|
||||
|
||||
# if self.user_id != self.journal_reply.user_id
|
||||
# receivers << self.journal_reply.user_id
|
||||
# end
|
||||
# # 给缺陷发布者发送
|
||||
# if self.user_id != self.issue.author_id && self.journal_reply.user_id != self.issue.author_id
|
||||
# receivers << self.issue.author_id
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,9 +56,14 @@ 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
|
||||
# 消息关联
|
||||
has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy
|
||||
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :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, :act_as_course_message, :act_as_user_feedback_message
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
@ -177,4 +182,77 @@ 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.m_parent_id.nil?
|
||||
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
|
||||
end
|
||||
end
|
||||
|
||||
# 课程/作品回复 留言消息通知
|
||||
def act_as_course_message
|
||||
if self.jour_type == 'StudentWorksScore'
|
||||
if self.user_id != self.jour.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
# 课程留言
|
||||
if self.jour_type == 'Course'
|
||||
receivers = []
|
||||
teachers = []
|
||||
# 获取课程的老师
|
||||
self.jour.members.each do |m|
|
||||
if m.user.allowed_to?(:as_teacher, self.jour)
|
||||
teachers << m
|
||||
end
|
||||
end
|
||||
if self.reply_id == 0 # 主留言,即不是回复某条留言
|
||||
teachers.each do |teacher|
|
||||
if teacher.user_id != self.user_id
|
||||
receivers << teacher.user_id
|
||||
end
|
||||
end
|
||||
else # 留言回复
|
||||
reply_to = User.find(self.reply_id)
|
||||
if self.user_id != self.reply_id # 添加我回复的那个人
|
||||
receivers << reply_to.id
|
||||
end
|
||||
# 给老师发送。 过滤条件:老师自己给自己发;回复对象为老师则排除改老师
|
||||
teachers.each do |teacher|
|
||||
if teacher.user_id != self.user_id && self.reply_id != teacher.user_id
|
||||
receivers << teacher.user_id
|
||||
end
|
||||
end
|
||||
end
|
||||
receivers.each do |r|
|
||||
self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 用户留言消息通知
|
||||
def act_as_user_feedback_message
|
||||
# 主留言
|
||||
if self.jour_type == 'Principal'
|
||||
receivers = []
|
||||
if self.reply_id == 0
|
||||
if self.user_id != self.jour_id # 过滤自己给自己的留言消息
|
||||
receivers << self.jour
|
||||
end
|
||||
else # 留言回复
|
||||
reply_to = User.find(self.reply_id)
|
||||
if self.user_id != self.reply_id # 添加我回复的那个人
|
||||
receivers << reply_to
|
||||
end
|
||||
if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发
|
||||
receivers << self.parent.jour
|
||||
end
|
||||
end
|
||||
receivers.each do |r|
|
||||
self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,8 +34,10 @@ class Mailer < ActionMailer::Base
|
|||
end
|
||||
def method_missing(name, *args, &block)
|
||||
if Setting.delayjob_enabled? && Object.const_defined?('Delayed')
|
||||
# with delayed_job
|
||||
@target.delay.send(name, *args, &block)
|
||||
else
|
||||
# without delayed_job
|
||||
@target.send(name, *args, &block).deliver
|
||||
end
|
||||
end
|
||||
|
@ -45,10 +47,67 @@ class Mailer < ActionMailer::Base
|
|||
MailerProxy.new(self)
|
||||
end
|
||||
|
||||
# 作业匿评开启
|
||||
def send_mail_anonymous_comment_open(homework_common)
|
||||
course = homework_common.course
|
||||
recipients ||= []
|
||||
course.members.each do |member|
|
||||
user = User.find(member.user_id)
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_close_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipients << user.mail
|
||||
end
|
||||
mail :to => recipients,
|
||||
:subject => @subject
|
||||
end
|
||||
|
||||
# 作业匿评关闭
|
||||
def send_mail_anonymous_comment_close(homework_common)
|
||||
course = homework_common.course
|
||||
recipients ||= []
|
||||
course.members.each do |member|
|
||||
user = User.find(member.user_id)
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_close)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_close_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipients << user.mail
|
||||
end
|
||||
mail :to => recipients,
|
||||
:subject => @subject
|
||||
end
|
||||
|
||||
# 匿评失败给老师发送邮件通知
|
||||
def send_mail_anonymous_comment_fail(homework_common)
|
||||
course = homework_common.course
|
||||
recipients ||= []
|
||||
# 只给该课程的老师发送邮件提醒
|
||||
course.members.each do |member|
|
||||
if member.user.allowed_to?(:as_teacher,course)
|
||||
user = User.find(member.user_id)
|
||||
@subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}"
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@anonymous_comment_fail_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipients << user.mail
|
||||
end
|
||||
end
|
||||
mail :to => recipients,
|
||||
:subject => @subject
|
||||
end
|
||||
|
||||
# author: alan
|
||||
# 发送邀请未注册用户加入项目邮件
|
||||
# 邀请未注册用户加入项目
|
||||
# 功能: 在加入项目的同时自动注册用户
|
||||
def send_invite_in_project(email, project, invitor)
|
||||
def send_invite_in_project(email, project, invitor, first_name, last_name, gender)
|
||||
@email = email
|
||||
@subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
|
||||
@password = newpass(6)
|
||||
|
@ -57,8 +116,8 @@ class Mailer < ActionMailer::Base
|
|||
login = login.sub(/%40/,'@')
|
||||
us = UsersService.new
|
||||
# 自动激活用户
|
||||
user = us.register_auto(login, @email, @password)
|
||||
InviteList.create(:user_id => user.id, :project_id => project.id)
|
||||
user = us.register_auto(login, email, @password, first_name, last_name, gender)
|
||||
InviteList.create(:user_id => user.id, :project_id => project.id, :mail =>email)
|
||||
User.current = user unless User.current.nil?
|
||||
@user = user
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
|
@ -74,15 +133,23 @@ class Mailer < ActionMailer::Base
|
|||
@project_name = "#{project.name}"
|
||||
@user = user
|
||||
@project = project
|
||||
inviter_lists = InviteList.where(project_id:@project.id, user_id:@user.id).all
|
||||
if inviter_lists.blank?
|
||||
InviteList.create(:user_id => user.id, :project_id => project.id)
|
||||
if InviteList.where("project_id= ? and user_id =? and mail =?", project.id, @user.id, email).first.nil?
|
||||
InviteList.create(:user_id => user.id, :project_id => project.id, :mail => email)
|
||||
end
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
|
||||
# 发送消息邀请
|
||||
send_message_request_member(user,project)
|
||||
# end
|
||||
mail :to => email, :subject => @subject
|
||||
end
|
||||
|
||||
# 邀请信息消息 注:forge_message_id 为邀请人ID(特殊情况)
|
||||
def send_message_request_member(user, project)
|
||||
key = newpass(6).to_s
|
||||
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key)
|
||||
end
|
||||
|
||||
# author: alan
|
||||
# 根据用户选择发送个人日报或周报
|
||||
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
|
||||
|
@ -201,11 +268,26 @@ class Mailer < ActionMailer::Base
|
|||
|
||||
has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments,
|
||||
@course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?}
|
||||
|
||||
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
|
||||
#有内容才发,没有不发
|
||||
mail :to => user.mail,:subject => subject if has_content
|
||||
end
|
||||
|
||||
# 作业截止时间邮件提醒
|
||||
def homework_endtime__added(homework_common, user_id)
|
||||
user = User.find(user_id)
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_homework_endtime)} "
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@homework_endtime_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => @subject
|
||||
end
|
||||
|
||||
# 公共讨论区发帖、回帖添加邮件发送信息
|
||||
def forum_message_added(memo)
|
||||
@memo = memo
|
||||
|
|
|
@ -30,6 +30,9 @@ class Member < ActiveRecord::Base
|
|||
validate :validate_role
|
||||
|
||||
before_destroy :set_issue_category_nil
|
||||
# 删除项目成员一并删除该成员的邀请记录
|
||||
after_destroy :delete_ivite_list
|
||||
|
||||
|
||||
|
||||
def role
|
||||
|
@ -98,6 +101,16 @@ class Member < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# 删除成员一并删除该成员的邀请信息
|
||||
def delete_ivite_list
|
||||
member_invite_lists = InviteList.where("user_id =? and project_id =?", self.user_id, self.project_id)
|
||||
unless member_invite_lists.nil?
|
||||
member_invite_lists.each do |member_invite_list|
|
||||
member_invite_list.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Find or initilize a Member with an id, attributes, and for a Principal
|
||||
def self.edit_membership(id, new_attributes, principal=nil)
|
||||
@membership = id.present? ? Member.find(id) : Member.new(:principal => principal)
|
||||
|
|
|
@ -16,6 +16,9 @@ class Memo < ActiveRecord::Base
|
|||
acts_as_attachable
|
||||
has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
# 消息
|
||||
has_many :memo_messages, :class_name =>'MemoMessage', :dependent => :destroy
|
||||
# end
|
||||
belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id'
|
||||
# acts_as_searchable :column => ['subject', 'content'],
|
||||
# #:include => { :forum => :p}
|
||||
|
@ -44,7 +47,7 @@ class Memo < ActiveRecord::Base
|
|||
"parent_id",
|
||||
"replies_count"
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!, :send_mail
|
||||
after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message
|
||||
# after_update :update_memos_forum
|
||||
after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分
|
||||
# after_create :send_notification
|
||||
|
@ -59,6 +62,32 @@ class Memo < ActiveRecord::Base
|
|||
Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added')
|
||||
end
|
||||
|
||||
# 公共贴吧消息记录
|
||||
# 原则:贴吧创始人;发帖人,wanglingchun(特殊用户)
|
||||
def send_message
|
||||
receivers = []
|
||||
u = User.find(6)
|
||||
receivers << u
|
||||
# 主贴
|
||||
if self.parent_id.nil?
|
||||
if self.author_id != self.forum.creator_id # 发帖人不是吧主
|
||||
receivers << self.forum.creator
|
||||
end
|
||||
else # 回帖
|
||||
# 添加吧主
|
||||
if self.author_id != self.forum.creator_id
|
||||
receivers << self.forum.creator
|
||||
end
|
||||
# 添加发帖人
|
||||
if self.author_id != self.parent.author_id && self.parent.author_id != self.forum.creator_id
|
||||
receivers << self.parent.author
|
||||
end
|
||||
end
|
||||
receivers.each do |r|
|
||||
self.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => self.forum_id, :memo_id => self.id, :memo_type => "Memo", :viewed => false)
|
||||
end
|
||||
end
|
||||
|
||||
def cannot_reply_to_locked_topic
|
||||
errors.add :base, l(:label_memo_locked) if root.locked? && self != root
|
||||
end
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class MemoMessage < ActiveRecord::Base
|
||||
attr_accessible :forum_id, :memo_id, :memo_type, :user_id, :viewed
|
||||
|
||||
belongs_to :memo
|
||||
belongs_to :user
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
|
||||
validates :user_id,presence: true
|
||||
validates :forum_id,presence: true
|
||||
validates :memo_id,presence: true
|
||||
validates :memo_type, presence: true
|
||||
after_create :add_user_message
|
||||
|
||||
def add_user_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -32,7 +32,13 @@ 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
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
|
@ -68,7 +74,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_system_message, :send_mail
|
||||
#before_save :be_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -80,7 +86,7 @@ class Message < ActiveRecord::Base
|
|||
}
|
||||
|
||||
|
||||
safe_attributes 'subject', 'content'
|
||||
safe_attributes 'subject', 'content', 'reply_id'
|
||||
safe_attributes 'board_id','locked', 'sticky',
|
||||
:if => lambda {|message, user|
|
||||
if message.project
|
||||
|
@ -186,10 +192,55 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程动态公共表记录
|
||||
def act_as_course_activity
|
||||
if self.course && self.parent_id.nil?
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
# 课程讨论区添加消息:
|
||||
# 老师发帖所有人都能收到消息
|
||||
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
|
||||
# 帖子被回复的可以收到消息通知
|
||||
# 项目讨论区添加消息:
|
||||
# 主贴项目成员都能收到
|
||||
# 回帖:帖子的发布人收到
|
||||
def act_as_system_message
|
||||
if self.course
|
||||
if self.parent_id.nil? # 主贴
|
||||
self.course.members.each do |m|
|
||||
if self.author.allowed_to?(:as_teacher, self.course) && 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
|
||||
else # 回帖
|
||||
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
|
||||
else # 项目相关
|
||||
if self.parent_id.nil? # 主贴
|
||||
self.project.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
else # 回帖
|
||||
self.project.members.each do |m|
|
||||
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建message且无parent的为发帖
|
||||
|
||||
if self.parent_id.nil? && !self.board.project.nil?
|
||||
UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id })
|
||||
update_memo_number(self.author,1)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class MessageAll < ActiveRecord::Base
|
||||
attr_accessible :message_id, :message_type, :user_id
|
||||
# 虚拟关联---项目消息表/课程消息表/用户留言消息表/贴吧消息表
|
||||
belongs_to :message ,:polymorphic => true
|
||||
end
|
|
@ -23,12 +23,18 @@ class News < ActiveRecord::Base
|
|||
#added by nwb
|
||||
belongs_to :course
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
||||
has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on"
|
||||
# fq
|
||||
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
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
||||
|
@ -49,7 +55,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_system_message, :add_author_as_watcher, :send_mail
|
||||
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
|
@ -115,12 +121,39 @@ class News < ActiveRecord::Base
|
|||
# Description 公用表中也要记录
|
||||
def act_as_forge_activity
|
||||
# 如果是project为空,那么是课程相关的,不需要保存
|
||||
if !self.project.nil?
|
||||
if self.project
|
||||
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
|
||||
:project_id => self.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.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
#课程/项目通知 消息发送
|
||||
#消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
|
||||
def act_as_system_message
|
||||
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
|
||||
else
|
||||
if !self.project.nil?
|
||||
self.project.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
# Description 删除news后删除对应的资源
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class OnclickTime < ActiveRecord::Base
|
||||
attr_accessible :onclick_time, :user_id
|
||||
|
||||
belongs_to :user
|
||||
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_save :act_as_course_message, :act_as_activity, :act_as_course_activity
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
|
||||
:description => :polls_description,
|
||||
|
@ -27,4 +32,30 @@ 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"
|
||||
if self.polls_status == 2 #问卷是发布状态
|
||||
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
|
||||
elsif self.polls_status == 1 #问卷是新建状态
|
||||
self.course_messages.destroy_all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -66,8 +66,8 @@ class Project < ActiveRecord::Base
|
|||
# has_many :students_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
|
||||
has_many :applied_projects
|
||||
has_many :invite_lists
|
||||
has_many :applied_projects, :dependent => :destroy
|
||||
has_many :invite_lists, :dependent => :destroy
|
||||
has_one :dts
|
||||
|
||||
# end
|
||||
|
@ -91,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, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
|
||||
belongs_to :organization
|
||||
|
||||
|
|
|
@ -492,26 +492,29 @@ class Query < ActiveRecord::Base
|
|||
|
||||
def project_statement
|
||||
project_clauses = []
|
||||
if project && !project.descendants.active.empty?
|
||||
ids = [project.id]
|
||||
if has_filter?("subproject_id")
|
||||
case operator_for("subproject_id")
|
||||
when '='
|
||||
# include the selected subprojects
|
||||
ids += values_for("subproject_id").each(&:to_i)
|
||||
when '!*'
|
||||
# main project only
|
||||
else
|
||||
# all subprojects
|
||||
ids += project.descendants.collect(&:id)
|
||||
end
|
||||
elsif Setting.display_subprojects_issues?
|
||||
ids += project.descendants.collect(&:id)
|
||||
end
|
||||
project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
|
||||
elsif project
|
||||
project_clauses << "#{Project.table_name}.id = %d" % project.id
|
||||
# unless project.descendants.blank?
|
||||
# if project && project.descendants && project.descendants.active && !project.descendants.active.empty?
|
||||
# ids = [project.id]
|
||||
# if has_filter?("subproject_id")
|
||||
# case operator_for("subproject_id")
|
||||
# when '='
|
||||
# # include the selected subprojects
|
||||
# ids += values_for("subproject_id").each(&:to_i)
|
||||
# when '!*'
|
||||
# # main project only
|
||||
# else
|
||||
# # all subprojects
|
||||
# ids += project.descendants.collect(&:id)
|
||||
# end
|
||||
# elsif Setting.display_subprojects_issues?
|
||||
# ids += project.descendants.collect(&:id)
|
||||
# end
|
||||
# project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
|
||||
# elsif project
|
||||
if project
|
||||
project_clauses << "#{Project.table_name}.id = %d" % project.id
|
||||
end
|
||||
# end
|
||||
project_clauses.any? ? project_clauses.join(' AND ') : nil
|
||||
end
|
||||
|
||||
|
|
|
@ -1,19 +1,139 @@
|
|||
#学生提交作品表
|
||||
class StudentWork < ActiveRecord::Base
|
||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id
|
||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test
|
||||
|
||||
belongs_to :homework_common
|
||||
belongs_to :user
|
||||
has_many :student_works_evaluation_distributions, :dependent => :destroy
|
||||
has_many :student_works_scores, :dependent => :destroy
|
||||
belongs_to :project
|
||||
has_many :student_work_test
|
||||
has_many :student_work_tests, order: 'id desc'
|
||||
|
||||
before_destroy :delete_praise
|
||||
before_save :set_program_score, :set_src
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
def delete_praise
|
||||
PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all
|
||||
end
|
||||
|
||||
def last_test
|
||||
student_work_tests.order('id desc').first
|
||||
end
|
||||
|
||||
private
|
||||
def set_program_score
|
||||
if homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分
|
||||
#根据最后一次测试计算得分
|
||||
unless last_test
|
||||
self.system_score = 0
|
||||
else
|
||||
self.system_score = last_test.test_score
|
||||
end
|
||||
end
|
||||
set_final_score self.homework_common,self
|
||||
end
|
||||
def set_src
|
||||
self.description = last_test.src if last_test
|
||||
end
|
||||
|
||||
#成绩计算
|
||||
def set_final_score homework,student_work
|
||||
if homework && homework.homework_detail_manual
|
||||
if homework.homework_type == 1 #匿评作业
|
||||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
elsif student_work.student_score.nil?
|
||||
student_work.final_score = student_work.teaching_asistant_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_manual.ta_proportion
|
||||
final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
elsif student_work.student_score.nil?
|
||||
student_work.final_score = student_work.teaching_asistant_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_manual.ta_proportion
|
||||
final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
|
||||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
elsif student_work.student_score.nil? #学生未评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
else
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
elsif student_work.student_score.nil? #学生未评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.system_score
|
||||
else
|
||||
ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
else
|
||||
final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
|
||||
final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
|
||||
final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
|
||||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# encoding: utf-8
|
||||
class StudentWorkTest < ActiveRecord::Base
|
||||
attr_accessible :student_work_id, :homework_test_id, :result, :error_msg
|
||||
|
||||
belongs_to :homework_test
|
||||
attr_accessible :student_work_id, :results, :status, :src
|
||||
belongs_to :student_work
|
||||
|
||||
serialize :results, Array
|
||||
|
||||
def status_to_s
|
||||
case self.result.to_i
|
||||
case self.status.to_i
|
||||
when -1
|
||||
'编译出错'
|
||||
when -2
|
||||
|
@ -33,10 +33,20 @@ class StudentWorkTest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def test_score
|
||||
if self.result.to_i == 0
|
||||
format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count)
|
||||
else
|
||||
if self.status.to_i == 0
|
||||
100
|
||||
elsif self.results.empty?
|
||||
0
|
||||
else
|
||||
get_success_count * 100 / self.results.count
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def get_success_count
|
||||
self.results.inject(0) do |sum, result|
|
||||
sum += (result["status"] && result["status"].to_i == 0 ? 1 : 0)
|
||||
end || 0
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#encoding=UTF-8
|
||||
class StudentWorksScore < ActiveRecord::Base
|
||||
#reviewer_role: 1:教师评分;2:教辅评分;3:学生匿评
|
||||
attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role
|
||||
|
@ -5,6 +6,35 @@ class StudentWorksScore < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :student_work
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
after_save :act_as_course_message
|
||||
|
||||
# 评阅作品消息提示
|
||||
def act_as_course_message
|
||||
if self.student_work && self.student_work.user && self.student_work.homework_common.course
|
||||
receiver = self.student_work.user
|
||||
# 判断是第一次评阅还是更新 status:0 新建;1 更新
|
||||
if self.created_at == self.updated_at
|
||||
if self.comment.nil?
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score}", :status=> false)
|
||||
else
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score} 评语:#{self.comment}", :status=> false)
|
||||
end
|
||||
else # 更新
|
||||
if self.comment.nil?
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score}", :status=> true)
|
||||
else
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score} 评语:#{self.comment}", :status=> true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class SystemMessage < ActiveRecord::Base
|
||||
attr_accessible :content, :id, :user_id, :description, :subject
|
||||
belongs_to :user
|
||||
|
||||
validates :subject, presence: true
|
||||
# validates :description, presence: true
|
||||
validates_length_of :description, maximum: 10000
|
||||
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
|
||||
# 系统消息放置总消息列表
|
||||
after_create :add_system_message
|
||||
|
||||
def add_system_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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,10 +127,20 @@ class User < Principal
|
|||
has_many :messages, :foreign_key => 'author_id'
|
||||
has_one :user_score, :dependent => :destroy
|
||||
has_many :documents # 项目中关联的文档再次与人关联
|
||||
# end
|
||||
# 关联消息表
|
||||
has_many :forge_messages
|
||||
has_many :course_messages
|
||||
has_many :memo_messages
|
||||
has_many :user_feedback_messages
|
||||
has_one :onclick_time
|
||||
has_many :system_messages
|
||||
|
||||
# 虚拟转换
|
||||
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
|
||||
has_many :invite_lists, :dependent => :destroy
|
||||
# end
|
||||
|
||||
######added by nie
|
||||
|
@ -150,7 +159,8 @@ class User < Principal
|
|||
nil
|
||||
}
|
||||
|
||||
|
||||
acts_as_attachable :view_permission => :view_files,
|
||||
:delete_permission => :manage_files
|
||||
acts_as_customizable
|
||||
############################added by william
|
||||
acts_as_taggable
|
||||
|
@ -197,13 +207,14 @@ class User < Principal
|
|||
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
|
||||
validate :validate_password_length
|
||||
# validates_email_realness_of :mail
|
||||
before_create :set_mail_notification
|
||||
before_create :set_mail_notification, :sync_gitlab_user
|
||||
before_save :update_hashed_password
|
||||
before_destroy :remove_references_before_destroy
|
||||
# added by fq
|
||||
after_create :act_as_activity
|
||||
after_create :act_as_activity, :add_onclick_time
|
||||
# end
|
||||
before_create :sync_gitlab_user
|
||||
# 更新邮箱用户或用户名的同事,同步更新邀请信息
|
||||
after_update :update_invite_list
|
||||
|
||||
scope :in_group, lambda {|group|
|
||||
group_id = group.is_a?(Group) ? group.id : group.to_i
|
||||
|
@ -236,10 +247,51 @@ 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
|
||||
if OnclickTime.where("user_id =?", User.current).first.nil?
|
||||
message_new_time = OnclickTime.new
|
||||
message_new_time.user_id = User.current.id
|
||||
# 第一次初始化点击铃铛时间
|
||||
message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on
|
||||
message_new_time.save
|
||||
end
|
||||
course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count
|
||||
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count
|
||||
end
|
||||
|
||||
# 查询指派给我的缺陷记录
|
||||
def issue_status_update
|
||||
self.status_updates
|
||||
end
|
||||
# end
|
||||
|
||||
def extensions
|
||||
self.user_extensions ||= UserExtensions.new
|
||||
end
|
||||
|
||||
# User现在可以作为一个Container_type,而Attachment的Container方法会有一个Container.try(:project),
|
||||
# 所以这里定义一个空方法,保证不报错
|
||||
def project
|
||||
|
||||
end
|
||||
|
||||
def user_score_attr
|
||||
self.user_score ||= UserScore.new
|
||||
end
|
||||
|
@ -259,7 +311,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
|
||||
|
@ -293,10 +345,6 @@ class User < Principal
|
|||
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
|
||||
|
@ -419,7 +467,7 @@ class User < Principal
|
|||
end
|
||||
|
||||
def nickname(formatter = nil)
|
||||
login
|
||||
login.nil? || (login && login.empty?) ? "AnonymousUser" : login
|
||||
end
|
||||
|
||||
def name(formatter = nil)
|
||||
|
@ -958,6 +1006,23 @@ class User < Principal
|
|||
self.acts << Activity.new(:user_id => self.id)
|
||||
end
|
||||
|
||||
# 注册用户的时候消息默认点击时间为用户创建时间
|
||||
def add_onclick_time
|
||||
if OnclickTime.where("user_id =?" , self.id).first.nil?
|
||||
OnclickTime.create(:user_id => self.id, :onclick_time => self.created_on)
|
||||
end
|
||||
end
|
||||
|
||||
# 更新邮箱的同事,更新invite_lists表中的邮箱信息
|
||||
def update_invite_list
|
||||
invite_lists = InviteList.where("user_id =?",self.id).all
|
||||
unless invite_lists.blank?
|
||||
invite_lists.each do |invite_list|
|
||||
invite_list.update_attribute(:mail, self.mail)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Removes references that are not handled by associations
|
||||
# Things that are not deleted are reassociated with the anonymous user
|
||||
def remove_references_before_destroy
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class UserActivity < ActiveRecord::Base
|
||||
attr_accessible :act_type,:act_id,:container_type,:container_id
|
||||
# 虚拟关联---项目动态表/课程动态表
|
||||
belongs_to :act ,:polymorphic => true
|
||||
# 虚拟关联---项目/课程
|
||||
belongs_to :container ,:polymorphic => true
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
class UserFeedbackMessage < ActiveRecord::Base
|
||||
attr_accessible :journals_for_message_id, :journals_for_message_type, :user_id, :viewed
|
||||
|
||||
belongs_to :journals_for_message
|
||||
belongs_to :user
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
|
||||
validates :user_id,presence: true
|
||||
validates :journals_for_message_id,presence: true
|
||||
validates :journals_for_message_type, presence: true
|
||||
after_save :add_user_message
|
||||
|
||||
def add_user_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -47,12 +47,16 @@ class UsersService
|
|||
end
|
||||
|
||||
# 自动注册功能 FOR:邮件邀请
|
||||
def register_auto(login,mail,password)
|
||||
def register_auto(login, mail, password, first_name, last_name, gender)
|
||||
mail_notification = "day"
|
||||
@user = User.new
|
||||
@user.admin = false
|
||||
@user.register
|
||||
@user.login = login
|
||||
@user.mail = mail
|
||||
@user.firstname = first_name
|
||||
@user.lastname = last_name
|
||||
@user.mail_notification = mail_notification
|
||||
password_confirmation = password
|
||||
should_confirmation_password = true
|
||||
if !password.blank? && !password_confirmation.blank? && should_confirmation_password
|
||||
|
@ -65,6 +69,7 @@ class UsersService
|
|||
@user = automatically_register_lock(@user)
|
||||
if @user.id != nil
|
||||
ue = @user.user_extensions ||= UserExtensions.new
|
||||
ue.gender = gender
|
||||
ue.user_id = @user.id
|
||||
ue.save
|
||||
end
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<%= stylesheet_link_tag 'new_user'%>
|
||||
<div class="homepageContent BgBox">
|
||||
<h2 class="BgBox_h2">关于我们</h2>
|
||||
<div class="AgreementBox">
|
||||
<p class="AgreementTxt">
|
||||
Trustie是一个面向高校创新实践的在线协作社区,是在中国高校推行大规模开放在线研究(Massive Open Online Research, MOORE)的支撑平台,也简称Trustie平台。老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。
|
||||
</p>
|
||||
<p class="AgreementTxt">
|
||||
MOORE是国防科学技术大学杨学军院士提出的一个面向高校科研教学活动的新型创新实践概念,为全面支持高校人才培养和科学研究提供了一种新思路。MOORE是对大规模在线开放课程(Massive Open Online Course, MOOC)的拓展,是课堂教学与创新实践深度结合的全新模式,可以看作MOOC2.0。
|
||||
</p>
|
||||
<p class="AgreementTxt">
|
||||
2005年开始,Trustie研制团队围绕网络时代的软件开发效率和质量这一核心问题展开研究,经过十年的磨砺与攻关,逐步揭示出以大众化协同开发、开放式资源共享、持续性可信评估为核心的互联网大规模协同机理,提出了全新的软件开发群体化方法。2008年起,研制团队开始探索如何将这种协同机理引入软件人才培养。MOORE概念的提出为研制团队的人才培养实践提供了新的发展方向和应用模式,使Trustie技术和工具能够更直接、更有效地与高校人才培养对接,形成了今天已被大量师生接受的在线人才培养平台。
|
||||
</p>
|
||||
<p class="AgreementTxt">
|
||||
研制团队认为MOORE的创新人才培养模式(如图1左图)是将互联网大规模协同机理与高校创新实践活动相结合的全新人才培养方法和模式,研制团队并基于本平台的架构形成了对MOORE核心机理的三方面认识(如图1右图)。
|
||||
</p>
|
||||
<div class="AgreementImg" >
|
||||
<img src="images/aboutus_01.jpg" width="619" height="215" />
|
||||
<p class="AgreementTxt T_C fb mt10">图1 基于MOORE的创新人才培养模式与核心机理</p>
|
||||
</div>
|
||||
<p class="AgreementTxt">
|
||||
目前,Trustie平台已经初步展现出大规模开放在线研究的生态系统蓝图,其核心是在线教学实践平台和在线协同研究平台,如图2。Trustie在线教学实践平台是支持教师和学生围绕课堂学习开展实践的平台(如图2),Trustie在线协同研究平台是支持开发小组围绕实践任务或研究工作开展分布式协作的平台(如图2)。两个核心平台为一名"新手"大学生成长为具有一定创新能力的"创客"提供了从学习到研究的一个渐进式成长环境(如图2)。
|
||||
</p>
|
||||
<p class="AgreementTxt">
|
||||
特别是,根据师生的实际需要,Trustie平台提供了私有模式和公开模式,支持针对未公开成果实施有效知识产权保护为前提的交流分享(如图2)。随着越来越多的高校、课程和研究小组的加入,MOORE创新实践模式的生态效益将不断显现出来。
|
||||
</p>
|
||||
<div class="AgreementImg" >
|
||||
<img src="images/aboutus_02.jpg" width="616" height="405" />
|
||||
<p class="AgreementTxt T_C fb mt10">图2 基于MOORE的支撑平台和生态系统</p>
|
||||
</div>
|
||||
<p class="AgreementTxt">
|
||||
研制团队特别感谢高校老师和学生的积极反馈、无私创意。平台的很多实用便捷的功能都是老师们积极参与和设计的结果,汇聚了大量师生的宝贵贡献,是研制团队和用户群体共同成长的结果。
|
||||
</p>
|
||||
<p class="AgreementTxt">
|
||||
Trustie平台的基本思路是将开源模式与中国高校人才培养活动相结合,但其本质上是一种O2O(Online To Offline)的创新人才培养模式,只有在以下两个方面同步推进,才能在持续解决实际需求的过程中快速发展:<br />
|
||||
(1)构建实践平台,激活创新能力:成为支持不同规模的团队进行协同研究和协同开发的实践平台,支持各类可公开的课程实验任务、教研室科研任务的在线协同,能够有效提升和评估学生的创新能力、协作能力和实践能力。<br />
|
||||
(2)引入开源理念,形成创客文化:将互联网开源软件运动中的自由、对等、共享、创新的理念引入高校,使"自主创意并亲自动手实现创意"的创客精神深入人才培养活动,在学生群体中形成大胆创意、大胆实践的创新文化。
|
||||
</p>
|
||||
<p class="AgreementTxt">
|
||||
研制团队认为,Trustie平台是一种"互联网+"思维在高校教育领域的大型探索性实践。作为一种互联网应用,Trustie平台自身的开发也采取了互联网模式:Trustie研制团队采用了"网构化软件开发模式",坚持"每周一更"的快速上线、快速体验模式,以最大程度上贴近用户实际需求提升。欢迎高校师生一同投身创新实践,共同见证MOORE创新生态的早日形成。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div><!---BgBox end--->
|
||||
|
||||
<div class="footer"></div>
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<%= stylesheet_link_tag 'new_user'%>
|
||||
<!--<div class="homepageContentContainer mb20" >-->
|
||||
<div class="homepageContent BgBox mt10">
|
||||
<h2 class="BgBox_h2">Trustie服务协议</h2>
|
||||
<div class="AgreementBox">
|
||||
<p>尊敬的用户,您好!<br />
|
||||
欢迎使用Trustie平台,在您使用Trustie平台前,请您认真阅读并遵守《Trustie服务协议》(以下简称"本协议"),请您务必审慎阅读、充分理解协议的各条款内容。<br />
|
||||
当您在注册过程中点击查看"看过并同意本服务协议",按照注册流程成功注册为Trustie平台的用户即表示您已充分阅读、理解并完全接受本协议中的全部条款。您承诺接受并遵守本协议的约定,届时您不应以未阅读本协议的内容等理由,主张本协议无效或本协议中的某些条款无效,或要求撤销本协议。</p>
|
||||
<h4 class="Agreementh4">一、Trustie平台权利和义务</h4>
|
||||
<p>1、尊重用户隐私:尊重用户隐私,保障用户隐私安全是Trustie平台的一项基本政策;<br />
|
||||
2、管理平台用户:Trustie平台依据国家法律、地方法律和国际法律等的标准以及本行业的规则来管理平台注册用户;<br />
|
||||
3、处理用户反馈:Trustie平台的相关人员会及时处理用户反馈的问题并给予及时回复。</p>
|
||||
<h4 class="Agreementh4">二、用户权利和义务</h4>
|
||||
<p>用户在使用Trustie平台的过程中,必须遵守如下原则:<br />
|
||||
1、遵守中国的有关法律和法规;<br />
|
||||
2、使用网络服务不作非法用途;<br />
|
||||
3、不干扰和混乱网络服务;<br />
|
||||
4、遵守所有使用网络服务的网络协议、规定、程序和惯例;<br />
|
||||
5、不传输任何非法的、骚扰性的、中伤他人的、辱骂性的、恐吓性的、伤害性的、庸俗的,淫秽等信息资料;<br />
|
||||
6、不传输任何教唆他人构成犯罪行为的资料;<br />
|
||||
7、用户不得故意或者过失损害Trustie平台合法权利和利益。及时回复。</p>
|
||||
<h4 class="Agreementh4">三、关于责任</h4>
|
||||
<p>鉴于网络服务的特殊性,用户同意Trustie团队有权在事先通知的情况下,变更、中断、升级部分网络服务。Trustie团队不担保网络服务不会中断,但承诺在用户可承受的时间内快速恢复服务,同时确保用户数据的安全性和可靠性。</p>
|
||||
<h4 class="Agreementh4">四、服务条款的修改</h4>
|
||||
<p>Trustie团队保留在必要时对本协议修改的权利,一旦发生变动,这些条款可由Trustie团队及时更新,且毋须另行通知,修改后的条款一旦在网页上公布即有效代替原来的服务条款。您可随时查阅最新版服务条款。</p>
|
||||
<p class=" mt15 fb">本协议最终解释权归Trustie团队所有。</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div><!---BgBox end--->
|
||||
<!--</div><!–-homepageContentContainer end-–>-->
|
||||
<script>
|
||||
$(".resourcesList").mousedown(function(e) {
|
||||
if (3 == e.which) {
|
||||
document.oncontextmenu = function() {return false;}
|
||||
$("#contextMenu").hide();
|
||||
$("#contextMenu").attr("style","display: block; position: fixed; top:"
|
||||
+ e.pageY
|
||||
+ "px; left:"
|
||||
+ e.pageX
|
||||
+ "px; width: 80px;");
|
||||
$("#contextMenu").show();
|
||||
}
|
||||
|
||||
});
|
||||
$(".resourcesList").click(function(e) {
|
||||
$("#contextMenu").hide();
|
||||
document.oncontextmenu = function() {return true;}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -1,17 +1,78 @@
|
|||
<% @nav_dispaly_home_path_label = 1
|
||||
@nav_dispaly_main_course_label = 1
|
||||
@nav_dispaly_main_project_label = 1
|
||||
@nav_dispaly_main_contest_label = 1 %>
|
||||
<% @nav_dispaly_forum_label = 1%>
|
||||
<%= call_hook :view_account_login_top %>
|
||||
<%= stylesheet_link_tag 'new_user'%>
|
||||
<%= stylesheet_link_tag 'leftside'%>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
function clearInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
if (text.val() == content) {
|
||||
$('#' + id).val('');
|
||||
<script type="text/javascript">
|
||||
|
||||
// $(document).ready(function(){
|
||||
// $("#loginSignButton").click(function(){
|
||||
// $("#signUpBox").css({display:"block"});
|
||||
// $("#loginInBox").css({display:"none"});
|
||||
// });
|
||||
// $("#loginInButton").click(function(){
|
||||
// $("#signUpBox").css({display:"none"});
|
||||
// $("#loginInBox").css({display:"block"});
|
||||
// });
|
||||
// });
|
||||
// $(function(){
|
||||
// $("#username").keypress(function(e){
|
||||
// alert(11);
|
||||
// if (e.keyCode == '13') {
|
||||
// $('#main_login_form').submit();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// $("#password").keypress(function(e){
|
||||
// if (e.keyCode == '13') {
|
||||
// $('#main_login_form').submit();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".homepageSearchIcon").click(function(){
|
||||
var val=$('input:radio[name="search_type"]:checked').val();
|
||||
if(val==null){
|
||||
$("#navSearchAlert").css({display:"block"});
|
||||
}
|
||||
else {
|
||||
$("#navSearchAlert").css({display:"none"});
|
||||
}
|
||||
});
|
||||
// $("#loginInButton").click(function(){
|
||||
// $("#signUpBox").css({display:"none"});
|
||||
// $("#loginInBox").css({display:"block"});
|
||||
// });
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".navHomepageSearchBoxcontainer").mouseover(function(){
|
||||
$(".navSearchTypeBox").css({display:"block"});
|
||||
});
|
||||
$(".navHomepageSearchBoxcontainer").mouseout(function(){
|
||||
$(".navSearchTypeBox").css({display:"none"});
|
||||
});
|
||||
})
|
||||
$(document).ready(function(){
|
||||
if(<%= @login%>){
|
||||
$("#signUpBox").css({display:"none"});
|
||||
$("#loginInBox").css({display:"block"});
|
||||
}else{
|
||||
$("#signUpBox").css({display:"block"});
|
||||
$("#loginInBox").css({display:"none"});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// $('#regist_btn').bind('keyup', function(event) {
|
||||
// if (event.keyCode == "13" && $("#signUpBox").css('display') == 'block')) {
|
||||
// register();
|
||||
// }
|
||||
//});
|
||||
function clearInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
if (text.val() == content) {
|
||||
$('#' + id).val('');
|
||||
}
|
||||
}
|
||||
|
||||
function showInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
|
@ -19,80 +80,207 @@
|
|||
$('#' + id).val(content);
|
||||
}
|
||||
}
|
||||
|
||||
function login(){
|
||||
$('#main_login_form').submit(); //表单提交没有任何反应的原因:js冲突
|
||||
}
|
||||
|
||||
function register(){
|
||||
if($login_correct && $mail_correct && $passwd_correct && $passwd_comfirm_correct && $("#read_and_confirm").attr("checked") == 'checked'){
|
||||
$("#main_reg_form").submit();
|
||||
}else{
|
||||
$('#user_login').blur();
|
||||
$('#user_mail').blur();
|
||||
$('#user_password').blur();
|
||||
$('#user_password_confirmation').blur();
|
||||
}
|
||||
}
|
||||
var $login_correct = false;
|
||||
var $mail_correct = false;
|
||||
var $passwd_correct = false;
|
||||
var $passwd_comfirm_correct = false;
|
||||
jQuery(document).ready(function () {
|
||||
var $login = $('#user_login')
|
||||
var $mail = $('#user_mail')
|
||||
var $password = $('#user_password')
|
||||
var $password_confirmation = $('#user_password_confirmation')
|
||||
$login.blur(function (event) {
|
||||
if ($(this).is('#user_login')) {
|
||||
$.get(
|
||||
'<%=account_valid_ajax_path%>',
|
||||
{ valid: "login",
|
||||
value: this.value },
|
||||
function (data) {
|
||||
if (data.valid) {
|
||||
$('#login_req').html('<span style="color: green">'+data.message+'</span>');
|
||||
$login_correct = true;
|
||||
} else {
|
||||
$('#login_req').html( '<span style="color: red">'+data.message+'</span>');
|
||||
$login_correct = false;
|
||||
}
|
||||
$('#login_req').css('display','block');
|
||||
});
|
||||
}
|
||||
;
|
||||
});
|
||||
|
||||
$mail.blur(function (event) {
|
||||
if ($(this).is('#user_mail')) {
|
||||
$.get('<%=account_valid_ajax_path%>',
|
||||
{ valid: "mail",
|
||||
value: this.value },
|
||||
function (data) {
|
||||
if (data.valid) {
|
||||
$('#mail_req').html( '<span style="color: green">'+data.message+'</span>' );
|
||||
$mail_correct = true;
|
||||
} else {
|
||||
$('#mail_req').html( '<span style="color: red">'+data.message+'</span>' );
|
||||
$mail_correct = false;
|
||||
}
|
||||
$('#mail_req').css('display','block');
|
||||
});
|
||||
}
|
||||
;
|
||||
});
|
||||
$password.blur(function () {
|
||||
var pas1 = document.getElementById("user_password").value;
|
||||
var password_min_length = <%= Setting.password_min_length.to_i %>
|
||||
if (pas1.length >= password_min_length) {
|
||||
$('#passwd_req').html('');
|
||||
$passwd_correct = true;
|
||||
}
|
||||
else {
|
||||
$('#passwd_req').html( '<span style="color: red">'+'<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'+'</span>');
|
||||
$passwd_correct = false;
|
||||
}
|
||||
$('#passwd_req').css('display','block');
|
||||
|
||||
|
||||
});
|
||||
$password_confirmation.blur(function () {
|
||||
var password_min_length = <%= Setting.password_min_length.to_i %>
|
||||
var pas1 = document.getElementById("user_password").value;
|
||||
var pas2 = document.getElementById("user_password_confirmation").value;
|
||||
if (pas1.length >= password_min_length && pas1 == pas2 ) {
|
||||
$('#confirm_req').html('<span style="color: green">'+'<%= l(:setting_password_success) %>'+'</span>');
|
||||
$passwd_comfirm_correct = true;
|
||||
}
|
||||
else {
|
||||
$('#confirm_req').html('<span style="color: red">'+'<%= l(:setting_password_error) %>'+'</span>');
|
||||
$passwd_comfirm_correct = false;
|
||||
|
||||
}
|
||||
$('#confirm_req').css('display','block');
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function user_name_keypress(e){
|
||||
if (e.keyCode == '13') {
|
||||
$('#main_login_form').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
|
||||
</head>
|
||||
<div id="login-form">
|
||||
<%= form_tag(signin_path) do %>
|
||||
<%= back_url_hidden_field_tag %>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<label for="username">
|
||||
<%=l(:lable_user_name)%>:
|
||||
</label>
|
||||
</td>
|
||||
<td align="left">
|
||||
<%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}",
|
||||
:onfocus => "clearInfo('username','#{l(:label_login_prompt)}')",
|
||||
:onblur => "showInfo('username','#{l(:label_login_prompt)}')",
|
||||
:style => "resize: none;font-size: 12px;color: #818283;"%>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<label for="password">
|
||||
<%=l(:field_password)%>:
|
||||
</label>
|
||||
</td>
|
||||
<td align="left">
|
||||
<%= password_field_tag 'password', nil, :tabindex => '2' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% if Setting.openid? %>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<label for="openid_url">
|
||||
<%=l(:field_identity_url)%>
|
||||
</label>
|
||||
</td>
|
||||
<td align="left">
|
||||
<%= text_field_tag "openid_url", nil, :tabindex => '3' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<% if Setting.autologin? %>
|
||||
<label for="autologin">
|
||||
<%= check_box_tag 'autologin', 1, true, :tabindex => 4 %>
|
||||
<%= l(:label_stay_logged_in) %>
|
||||
</label>
|
||||
<div class="loginContentContainer">
|
||||
<div class="loginContent">
|
||||
<div class="loginLeft">
|
||||
<div class="loginLogo"><img src="images/trustie_big_log.png" width="100" height="88" alt="Trustie Logo" /></div>
|
||||
<div class="loginInro"> 欢迎加入Trustie高校创新实践社区!老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。<br/><br/> Trustie是在中国推行大规模开放在线研究模式(MOORE)的支撑平台。</div>
|
||||
</div>
|
||||
<div class="loginRight">
|
||||
<div id="loginInBox">
|
||||
<div class="loginChooseBox">
|
||||
<div class="mb5">
|
||||
<ul class="loginChooseList">
|
||||
<li class="loginChoose fl"><span class="loginChooseTab">登录</span></li>
|
||||
<li class="loginChooseBorder fl"></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="loginSignAlert" style="color: red"><%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %></div>
|
||||
</div>
|
||||
<div class="loginIn">
|
||||
|
||||
<%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %>
|
||||
<%= back_url_hidden_field_tag %>
|
||||
<div class="mb20">
|
||||
<%= text_field_tag 'username', params[:username], :tabindex => '1' ,
|
||||
:class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%>
|
||||
<!--<input type="text" placeholder="请输入邮箱地址或昵称" class="loginSignBox" />-->
|
||||
</div>
|
||||
<% if Setting.openid? %>
|
||||
<div class="mb20">
|
||||
<%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div>
|
||||
<!--<input type="text" placeholder="请输密码" class="loginSignBox" />-->
|
||||
<%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%>
|
||||
</div>
|
||||
<div class="loginSignOption">
|
||||
<% if Setting.autologin? %>
|
||||
<div class="fl mt3 mr5">
|
||||
<%= check_box_tag 'autologin', 1, true, :tabindex => 4 %>
|
||||
</div>
|
||||
<%= l(:label_stay_logged_in) %>
|
||||
<% end %>
|
||||
<a href="<%= lost_password_path %>" class="newsBlue mr40 fr">
|
||||
<% if Setting.lost_password? %>
|
||||
<u>忘记密码?</u>
|
||||
<% end %>
|
||||
</a></div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" >
|
||||
<div class="loginInButton" >
|
||||
<a href="javascript:void(0);" id="login_btn" class="c_white db" onclick="$('#main_login_form').submit();">登录</a>
|
||||
</div>
|
||||
|
||||
<span style="float: left">
|
||||
<% if Setting.lost_password? %>
|
||||
<%= link_to l(:label_password_lost), lost_password_path %>
|
||||
<% end %></span>
|
||||
</div>
|
||||
|
||||
<span style="float: right">
|
||||
<input type="submit" class="small" name="login" value="<%=l(:button_login)%> »" tabindex="5"/></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="signUpBox">
|
||||
<div class="loginChooseBox">
|
||||
<ul class="loginChooseList">
|
||||
<li class="loginChoose fl"><span class="loginChooseTab">注册<%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></a></span>
|
||||
<li class="loginChooseBorder fl"></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="loginIn">
|
||||
<%= form_for :user, :url => register_path,:method=>'post',:html=>{:id=>'main_reg_form'} do |f| %>
|
||||
<%= error_messages_for 'user' %>
|
||||
<div class="loginSignRow">
|
||||
<!--<input type="text" placeholder="请输入邮箱地址" class="loginSignBox" />-->
|
||||
<%= f.text_field :mail,:size => 25, :class=>'loginSignBox' ,:placeholder=>"请输入邮箱地址"%>
|
||||
<div class="loginSignAlert" id="mail_req" style="display: none" >请输入有效邮箱地址</div>
|
||||
</div>
|
||||
<div class="loginSignRow">
|
||||
<!--<input type="text" placeholder="请输入密码" class="loginSignBox" />-->
|
||||
<%= f.password_field :password, :size => 25,:placeholder=>"请输入密码",:class=>'loginSignBox' %>
|
||||
<div class="loginSignAlert" id="passwd_req" style="display: none">至少需要 6 个字符</div>
|
||||
</div>
|
||||
<div class="loginSignRow">
|
||||
<!--<input type="text" placeholder="请再次输入密码" class="loginSignBox" />-->
|
||||
<%= f.password_field :password_confirmation, :size => 25,:placeholder=>"请再次输入密码",:class=>'loginSignBox' %>
|
||||
<div class="loginSignAlert" id="confirm_req" style="display: none">密码不一致</div>
|
||||
</div>
|
||||
<div class="loginSignRow">
|
||||
<!--<input type="text" placeholder="请输入用户昵称" class="loginSignBox" />-->
|
||||
<%= f.text_field :login, :size => 25,:placeholder=>"请输入用户昵称",:class=>'loginSignBox'%>
|
||||
<div class="loginSignAlert" id="login_req" style="display: none">用户昵称为2-18个中英文,数字或下划线</div>
|
||||
</div>
|
||||
<div class="loginSignOption">
|
||||
<div class="fl mt3 mr5">
|
||||
<input type="checkbox" id="read_and_confirm"/>
|
||||
</div>
|
||||
我已阅读并接受<a href="<%= agreement_path %>" class="newsBlue"><u>Trustie服务协议</u></a>条款</div>
|
||||
<div class="loginUpButton">
|
||||
<a href="javascript:void(0);" class="c_white db" id="regist_btn" onclick="register();">注册</a>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<%= call_hook :view_account_login_bottom %>
|
||||
|
||||
<% if params[:username].present? %>
|
||||
<%= javascript_tag "$('#password').focus();" %>
|
||||
<% else %>
|
||||
<%= javascript_tag "$('#username').focus();" %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
<% @nav_dispaly_home_path_label = 1
|
||||
@nav_dispaly_main_course_label = 1
|
||||
@nav_dispaly_main_project_label = 1
|
||||
@nav_dispaly_main_contest_label = 1 %>
|
||||
<% @nav_dispaly_forum_label = 1%>
|
||||
<h3><%=l(:label_password_forget)%></h3>
|
||||
<%= stylesheet_link_tag 'new_user'%>
|
||||
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||
<%= text_field_tag 'mail', nil, :size => 40, :placeholder => '请输入注册邮箱'%>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="homepageContentContainer ">
|
||||
<div class="homepageContent BgBox">
|
||||
<h2 class="BgBox_h2">忘记密码</h2>
|
||||
<div class="BgBoxCon">
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
<p class="BgBoxConP mb5">通过注册邮箱链接重设密码</p>
|
||||
<!--<input type="text" class="NomalInput mb20 " value="请输入登录邮箱地址" />-->
|
||||
<%= text_field_tag 'mail', nil, :size => 40, :placeholder => '请输入注册邮箱',:class=>'NomalInput mb20'%>
|
||||
<% if flash[:error] %>
|
||||
<p class="c_red mt-20 ml5"><%= flash[:error]%></p>
|
||||
<!--<div style="color: red" class="mb5" ><%#= flash[:error]%></div>-->
|
||||
<% elsif flash[:notice] %>
|
||||
<p class="c_green mb5"><%= flash[:notice]%></p>
|
||||
<!--<div style="color: green" class="mb5" ><%#= flash[:notice]%></div>-->
|
||||
<% end %>
|
||||
<div class="LoginButton"><a href="javascript:void(0);" class="c_white db" onclick="$(this).parent().parent().submit();">提交</a></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
</div><!---BgBox end--->
|
||||
</div><!---homepageContentContainer end--->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
<h3><%=l(:label_password_lost)%></h3>
|
||||
|
||||
<%= error_messages_for 'user' %>
|
||||
<div style="margin-top:20px;width:100%; background-color:#eaebed;">
|
||||
<div style="width:1000px; background-color:#eaebed; margin:0 auto; width:968px; border:1px solid #dddddd; background:#fff; padding:15px; padding-top:10px;margin: 20px auto">
|
||||
<h2 style="font-size:16px; color:#484848; width:968px;border-bottom:1px solid #e3e3e3; padding-bottom:5px;">重置密码</h2>
|
||||
<div style="width:310px; margin:80px auto;">
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
<%= hidden_field_tag 'token', @token.value %>
|
||||
<!--<input type="text" class="NomalInput " value="新密码" />-->
|
||||
<%= password_field_tag 'new_password', nil, :size => 25,:placeholder=>'新密码',:style=>"width:308px; height:38px; border:1px solid #98a1a6; outline:none; color:#888888; font-size:14px; " %>
|
||||
<p style=" color:#F00 ;margin-bottom:5px;">至少需要 6 个字符</p>
|
||||
<!--<input type="text" class="NomalInput mb20 " value="确定密码" />-->
|
||||
<%= password_field_tag 'new_password_confirmation', nil, :size => 25,:placeholder=>'确定密码',:style=>"width:308px; height:38px; border:1px solid #98a1a6; outline:none; color:#888888; font-size:14px;margin-bottom:20px; " %>
|
||||
<div style="width:315px; height:40px; background-color:#269ac9; font-size:14px; text-align:center; line-height:40px; vertical-align:middle;"><a href="javascript:void(0);" style=" color:#fff;display:block !important;" onclick="$(this).parent().parent().submit();">提交</a></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
<%= hidden_field_tag 'token', @token.value %>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password', nil, :size => 25 %>
|
||||
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="new_password_confirmation"><%= l(:field_password_confirmation)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>
|
||||
</p>
|
||||
</div>
|
||||
<p><%= submit_tag l(:button_save) %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</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,69 @@
|
|||
<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;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="来源(课程ID)">
|
||||
来源(课程ID)
|
||||
</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=@page*30%>
|
||||
<% 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 %>'>
|
||||
<%= link_to(course.subject, course_boards_path(Board.where('id=?',course.board_id).first.course_id)) %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= link_to(course.replies_count, course_boards_path(Board.where('id=?',course.board_id).first.course_id)) %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
|
@ -0,0 +1,66 @@
|
|||
<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=@page*30 %>
|
||||
<% 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">
|
||||
<%=link_to(StudentWork.where('homework_common_id=?',homework.id).count, student_work_index_path(:homework => homework.id))%>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_date(homework.end_time) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_user_homework)) -%>
|
|
@ -0,0 +1,98 @@
|
|||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
|
||||
<h3>
|
||||
<%=l(:label_latest_login_user_list)%>
|
||||
</h3>
|
||||
|
||||
<%= form_tag({}, :method => :get) do %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
</legend>
|
||||
<label style="float:left">开始日期:</label>
|
||||
<%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
|
||||
<%= calendar_for('startdate')%><span style="float: left "> </span>
|
||||
<label style="float:left">结束日期:</label>
|
||||
<%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
|
||||
<%= calendar_for('enddate')%>
|
||||
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
|
||||
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_users'}, :class => 'icon icon-reload' %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<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=@page * 30 %>
|
||||
<% for user in @user do %>
|
||||
<tr>
|
||||
<% @count +=1 %>
|
||||
<td align="center">
|
||||
<%=@count %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_time(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">
|
||||
<%if user.user_extensions%>
|
||||
<% case user.user_extensions.identity %>
|
||||
<% when 0 %>
|
||||
<%='老师' %>
|
||||
<% when 1 %>
|
||||
<%='学生' %>
|
||||
<% when 2 %>
|
||||
<%='企业' %>
|
||||
<% when 3 %>
|
||||
<%='开发者' %>
|
||||
<% else %>
|
||||
<%='未知身份' %>
|
||||
<% end %>
|
||||
<% end%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_latest_login_user_list)) -%>
|
|
@ -0,0 +1,96 @@
|
|||
<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; white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="来源(课程或用户ID)">
|
||||
来源(课程或用户ID)
|
||||
</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 = @page * 30 %>
|
||||
<% 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" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<% if journal.try(:user).try(:realname) == ' '%><%= journal.try(:user)%><% else %><%=journal.try(:user).try(:realname) %><% end %>'>
|
||||
<% if journal.try(:user).try(:realname) == ' '%>
|
||||
<%= link_to(journal.try(:user), user_path(journal.user)) %>
|
||||
<% else %>
|
||||
<%= link_to(journal.try(:user).try(:realname), user_path(journal.user)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= format_date(journal.created_on) %>
|
||||
</td>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=journal.notes %>'>
|
||||
<%case journal.jour_type %>
|
||||
<% when 'Principal' %>
|
||||
<%= link_to(journal.notes.html_safe, feedback_path(journal.jour_id)) %>
|
||||
<% when 'Course' %>
|
||||
<%= link_to(journal.notes.html_safe, course_feedback_path(journal.jour_id)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<% if(journal.m_reply_count) %>
|
||||
<%case journal.jour_type %>
|
||||
<% when 'Principal' %>
|
||||
<%= link_to(journal.m_reply_count, feedback_path(journal.jour_id)) %>
|
||||
<% when 'Course' %>
|
||||
<%= link_to(journal.m_reply_count, course_feedback_path(journal.jour_id)) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%case journal.jour_type %>
|
||||
<% when 'Principal' %>
|
||||
<%= link_to(0, feedback_path(journal.jour_id)) %>
|
||||
<% when 'Course' %>
|
||||
<%= link_to(0, course_feedback_path(journal.jour_id)) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_leave_message_list)) -%>
|
|
@ -0,0 +1,64 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
<h3 style="float: left">
|
||||
<%=l(:label_system_message)%>
|
||||
</h3><br/>
|
||||
<div style="padding-top: 20px; padding-left: 5px;">
|
||||
<%= form_for(@admin_messages, :html => {:id =>'system_messages-form'}) do |f| %>
|
||||
<li>
|
||||
<label><span class="">*</span> <%= l(:field_title) %> :</label>
|
||||
<input type="text" name="system_message[subject]" class="hwork_input_news" id="system_message_subject" width="576px" onblur="regexTitle($(this));" maxlength="255" placeholder="255个字符以内" value="">
|
||||
<p id="title_notice_span" class="ml55"></p>
|
||||
</li>
|
||||
<li>
|
||||
<label class="fl" > <span class="c_red"></span> <%= l(:field_description) %> :</label>
|
||||
<%= f.kindeditor :description,:width=>'87.5%',:editor_id=>'system_message_editor' %>
|
||||
<p id="content_notice_span" class="ml55"></p>
|
||||
</li>
|
||||
<div>
|
||||
<p id="content_notice_span" class="ml55"></p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= link_to l(:label_submit), "javascript:void(0)", :class => "btn_message_free", :onclick => "system_message_editor.sync();submit_message();" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<script>
|
||||
function system_message_length() {
|
||||
var obj = system_message_editor.html();
|
||||
if (obj.length > 10000) {
|
||||
$("#content_notice_span").text("内容过长,超过10000个字符");
|
||||
$("#content_notice_span").css('color', '#ff0000');
|
||||
$("#content_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$("#content_notice_span").text("填写正确");
|
||||
$("#content_notice_span").css('color', '#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function regexTitle(obj){
|
||||
var title = obj.val();
|
||||
if(title.length == 0)
|
||||
{
|
||||
$("#title_notice_span").text("标题不能为空").css("color", "#ff0000").focus();
|
||||
return false;
|
||||
}
|
||||
else if(title.length > 255)
|
||||
{
|
||||
$("#title_notice_span").text("标题长度过长,不能超过255个字符").css("color", "#ff0000").focus();
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
$("#title_notice_span").text("填写正确").css("color", "#008000");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function submit_message() {
|
||||
|
||||
if (system_message_length() && regexTitle($("#system_message_subject"))) {
|
||||
$("#system_messages-form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<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; white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="来源(贴吧ID)">
|
||||
来源(贴吧ID)
|
||||
</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=@page * 30%>
|
||||
<% 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 %>'>
|
||||
<% if memo.parent_id.nil? || memo.subject.starts_with?('RE:')%>
|
||||
<%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %>
|
||||
<% else %>
|
||||
<%= link_to("RE:"+memo.subject, forum_memo_path(memo.forum, memo)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
|
@ -0,0 +1,78 @@
|
|||
<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=@page * 30%>
|
||||
<% 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">
|
||||
<%= link_to(news.comments_count, news_path(news)) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_notification_list)) -%>
|
|
@ -0,0 +1,70 @@
|
|||
<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;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="来源(项目ID)">
|
||||
来源(项目ID)
|
||||
</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=@page * 30 %>
|
||||
<% 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">
|
||||
<%= link_to(project.subject, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %>
|
||||
</td>
|
||||
<td class="center">
|
||||
<%= link_to(project.replies_count, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_message_plural)) -%>
|
|
@ -65,7 +65,7 @@
|
|||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
||||
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
|
||||
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
|
||||
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
|
||||
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del', :onClick=>"delcfm()" ) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
@ -74,3 +74,11 @@
|
|||
</div>
|
||||
|
||||
<% html_title(l(:label_project_plural)) -%>
|
||||
|
||||
<script>
|
||||
function delcfm() {
|
||||
if (!confirm("删除项目会一并删除项目的关联信息,确认要删除吗?")) {
|
||||
window.event.returnValue = false;
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -23,6 +23,7 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<% project = project %>
|
||||
<span class="add_attachment" style="font-weight:normal;">
|
||||
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn', :style => ie8? ? 'display:none' : '' %>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<% 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%>
|
||||
|
|
|
@ -1,26 +1,38 @@
|
|||
<h3><%=h @attachment.filename %></h3>
|
||||
<div id="wrapper">
|
||||
<div id="wrapper2">
|
||||
<div id="wrapper3">
|
||||
<div id="main" class="nosidebar">
|
||||
<div id="content_">
|
||||
<h3><%=h @attachment.filename %></h3>
|
||||
|
||||
<div class="attachments">
|
||||
<p><%= h("#{@attachment.description} - ") unless @attachment.description.blank? %>
|
||||
<span class="author"><%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %></span></p>
|
||||
<p><%= link_to_attachment @attachment, :text => l(:button_download), :download => true -%>
|
||||
<span class="size">(<%= number_to_human_size @attachment.filesize %>)</span>   
|
||||
<span class="size">
|
||||
<% if @attachment!=nil &&(@attachment.container_type == 'Document' || @attachment.container_type == 'WikiPage') &&
|
||||
User.current.allowed_to?({:controller => 'code_review', :action => 'update_diff_view'}, @attachment.project) %>
|
||||
<%= l(:review_assignments)+":" %><%= link = link_to(l(:button_add), {:controller => 'code_review',
|
||||
:action => 'assign', :action_type => 'attachment',
|
||||
:id=>@attachment.project,
|
||||
:change_id => '', :attachment_id => @attachment.id,
|
||||
}, :class => 'icon icon-add') %>
|
||||
<% end %>
|
||||
</span></p>
|
||||
<div class="attachments">
|
||||
<p><%= h("#{@attachment.description} - ") unless @attachment.description.blank? %>
|
||||
<span class="author"><%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %></span></p>
|
||||
<p><%= link_to_attachment @attachment, :text => l(:button_download), :download => true -%>
|
||||
<span class="size">(<%= number_to_human_size @attachment.filesize %>)</span>   
|
||||
<span class="size">
|
||||
<% if @attachment!=nil &&(@attachment.container_type == 'Document' || @attachment.container_type == 'WikiPage') &&
|
||||
User.current.allowed_to?({:controller => 'code_review', :action => 'update_diff_view'}, @attachment.project) %>
|
||||
<%= l(:review_assignments)+":" %><%= link = link_to(l(:button_add), {:controller => 'code_review',
|
||||
:action => 'assign', :action_type => 'attachment',
|
||||
:id=>@attachment.project,
|
||||
:change_id => '', :attachment_id => @attachment.id,
|
||||
}, :class => 'icon icon-add') %>
|
||||
<% end %>
|
||||
</span></p>
|
||||
</div>
|
||||
|
||||
<%= render :partial => 'common/file', :locals => {:content => @content, :filename => @attachment.filename} %>
|
||||
|
||||
<% html_title @attachment.filename %>
|
||||
|
||||
<% content_for :header_tags do -%>
|
||||
<%= stylesheet_link_tag "scm" -%>
|
||||
<% end -%>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render :partial => 'common/file', :locals => {:content => @content, :filename => @attachment.filename} %>
|
||||
|
||||
<% html_title @attachment.filename %>
|
||||
|
||||
<% content_for :header_tags do -%>
|
||||
<%= stylesheet_link_tag "scm" -%>
|
||||
<% end -%>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue