Compare commits
No commits in common. "master" and "CourseModify" have entirely different histories.
master
...
CourseModi
|
|
@ -13,4 +13,3 @@
|
|||
/Gemfile.lock
|
||||
/db/schema.rb
|
||||
/Gemfile.lock
|
||||
/lib/plugins/acts_as_versioned/test/debug.log
|
||||
|
|
|
|||
23
Gemfile
23
Gemfile
|
|
@ -25,15 +25,6 @@ group :development do
|
|||
end
|
||||
end
|
||||
|
||||
group :test do
|
||||
#gem "shoulda", "~> 3.3.2"
|
||||
gem "shoulda", "> 3.3.2"
|
||||
gem "mocha", "~> 0.13.3"
|
||||
gem 'capybara', '~> 2.0.0'
|
||||
gem 'nokogiri', '< 1.6.0'
|
||||
end
|
||||
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
group :assets do
|
||||
|
|
@ -41,7 +32,7 @@ group :assets do
|
|||
gem 'coffee-rails', '~> 3.2.1'
|
||||
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
gem 'therubyracer', :platforms => :ruby
|
||||
# gem 'therubyracer', :platforms => :ruby
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
end
|
||||
|
|
@ -51,16 +42,6 @@ group :ldap do
|
|||
gem "net-ldap", "~> 0.3.1"
|
||||
end
|
||||
|
||||
|
||||
platforms :mri, :mingw do
|
||||
group :rmagick do
|
||||
# RMagick 2 supports ruby 1.9
|
||||
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
|
||||
# different requirements for the same gem on different platforms
|
||||
gem "rmagick", ">= 2.0.0"
|
||||
end
|
||||
end
|
||||
|
||||
# Optional gem for OpenID authentication
|
||||
group :openid do
|
||||
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||
|
|
@ -86,7 +67,7 @@ if File.exist?(database_file)
|
|||
adapters.each do |adapter|
|
||||
case adapter
|
||||
when 'mysql2'
|
||||
gem "mysql2", "= 0.3.11", :platforms => [:mri, :mingw]
|
||||
gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
|
||||
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
|
||||
when 'mysql'
|
||||
gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
|
||||
|
|
|
|||
51
Gemfile.lock
51
Gemfile.lock
|
|
@ -52,15 +52,6 @@ GEM
|
|||
rails (>= 3, < 5)
|
||||
arel (3.0.2)
|
||||
builder (3.0.0)
|
||||
capybara (2.0.3)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 1.0.0)
|
||||
childprocess (0.5.3)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
coderay (1.0.9)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
|
|
@ -68,11 +59,11 @@ GEM
|
|||
coffee-script (2.2.0)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.7.0)
|
||||
coffee-script-source (1.6.1)
|
||||
erubis (2.7.0)
|
||||
execjs (2.0.2)
|
||||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
fastercsv (1.5.0)
|
||||
ffi (1.9.3-x86-mingw32)
|
||||
hike (1.2.3)
|
||||
i18n (0.6.1)
|
||||
journey (1.0.4)
|
||||
|
|
@ -83,14 +74,10 @@ GEM
|
|||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.4)
|
||||
mime-types (1.23)
|
||||
mocha (0.13.3)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.7.6)
|
||||
mysql2 (0.3.11-x86-mingw32)
|
||||
net-ldap (0.3.1)
|
||||
nokogiri (1.5.11-x86-mingw32)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
|
|
@ -117,28 +104,15 @@ GEM
|
|||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.3.2)
|
||||
rake (10.0.4)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
rmagick (2.13.2)
|
||||
ruby-openid (2.1.8)
|
||||
rubyzip (1.1.4)
|
||||
sass (3.2.14)
|
||||
sass (3.2.7)
|
||||
sass-rails (3.2.6)
|
||||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
tilt (~> 1.3)
|
||||
selenium-webdriver (2.42.0)
|
||||
childprocess (>= 0.5.0)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip (~> 1.0)
|
||||
websocket (~> 1.0.4)
|
||||
shoulda (3.5.0)
|
||||
shoulda-context (~> 1.0, >= 1.0.1)
|
||||
shoulda-matchers (>= 1.4.1, < 3.0)
|
||||
shoulda-context (1.2.1)
|
||||
shoulda-matchers (2.6.1)
|
||||
activesupport (>= 3.0.0)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
|
|
@ -150,12 +124,9 @@ GEM
|
|||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.37)
|
||||
uglifier (2.4.0)
|
||||
uglifier (1.0.3)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
websocket (1.0.7)
|
||||
xpath (1.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
multi_json (>= 1.0.2)
|
||||
|
||||
PLATFORMS
|
||||
x86-mingw32
|
||||
|
|
@ -166,23 +137,17 @@ DEPENDENCIES
|
|||
acts-as-taggable-on (= 2.4.1)
|
||||
better_errors!
|
||||
builder (= 3.0.0)
|
||||
capybara (~> 2.0.0)
|
||||
coderay (~> 1.0.6)
|
||||
coffee-rails (~> 3.2.1)
|
||||
fastercsv (~> 1.5.0)
|
||||
i18n (~> 0.6.0)
|
||||
jquery-rails (~> 2.0.2)
|
||||
mocha (~> 0.13.3)
|
||||
mysql2 (= 0.3.11)
|
||||
mysql2 (~> 0.3.11)
|
||||
net-ldap (~> 0.3.1)
|
||||
nokogiri (< 1.6.0)
|
||||
rack-mini-profiler!
|
||||
rack-openid
|
||||
rails (= 3.2.13)
|
||||
rmagick (>= 2.0.0)
|
||||
ruby-openid (~> 2.1.4)
|
||||
sass-rails (~> 3.2.3)
|
||||
seems_rateable!
|
||||
shoulda (> 3.3.2)
|
||||
therubyracer
|
||||
uglifier (>= 1.0.3)
|
||||
|
|
|
|||
|
|
@ -143,18 +143,15 @@ class AccountController < ApplicationController
|
|||
end
|
||||
|
||||
#added by bai
|
||||
if @user.id != nil
|
||||
ue = @user.user_extensions ||= UserExtensions.new
|
||||
#ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => )
|
||||
ue.identity = params[:identity].to_i
|
||||
ue.technical_title = params[:technical_title]
|
||||
ue.gender = params[:gender].to_i
|
||||
ue.user_id = @user.id
|
||||
ue.student_id = params[:no]
|
||||
ue.location = params[:province] if params[:province] != nil
|
||||
ue.location_city = params[:city] if params[:city] != nil
|
||||
ue.save
|
||||
unless @user.id.nil?
|
||||
ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => params[:no])
|
||||
unless params[:province].nil? || params[:city].nil?
|
||||
ue.location = params[:province]
|
||||
ue.location_city = params[:city]
|
||||
ue.save
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class ApplicationController < ActionController::Base
|
|||
Setting.check_cache
|
||||
# Find the current user
|
||||
User.current = find_current_user
|
||||
#logger.info(" Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})" : "anonymous")) if logger
|
||||
logger.info(" Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})" : "anonymous")) if logger
|
||||
end
|
||||
|
||||
# Returns the current user or nil if no user is logged in
|
||||
|
|
@ -300,7 +300,7 @@ class ApplicationController < ActionController::Base
|
|||
render_404
|
||||
end
|
||||
|
||||
#<EFBFBD><EFBFBD><EFBFBD>course_id<EFBFBD><EFBFBD>project
|
||||
#根据course_id找project
|
||||
def find_project_by_course_id
|
||||
@bid = Bid.find params[:course_id]
|
||||
@project = @bid.courses[0]
|
||||
|
|
@ -354,7 +354,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
#added by nwb
|
||||
#<EFBFBD><EFBFBD>ȡ<EFBFBD>γ<EFBFBD>
|
||||
#获取课程
|
||||
def find_course
|
||||
@course= Course.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
|||
|
|
@ -59,8 +59,6 @@ class AttachmentsController < ApplicationController
|
|||
:type => detect_content_type(@attachment),
|
||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||
end
|
||||
rescue => e
|
||||
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
|
||||
end
|
||||
|
||||
#更新资源文件类型
|
||||
|
|
@ -161,13 +159,7 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
|
||||
def autocomplete
|
||||
# modify by nwb
|
||||
if params[:project_id]
|
||||
@project = Project.find_by_id(params[:project_id])
|
||||
elsif params[:course_id]
|
||||
@course = Course.find_by_id(params[:course_id])
|
||||
end
|
||||
|
||||
@project = Project.find_by_id(params[:project_id])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
@ -203,35 +195,6 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def add_exist_file_to_course
|
||||
class_id = params[:class_id]
|
||||
attachments = params[:attachment][:attach]
|
||||
|
||||
obj = Course.find_by_id(class_id)
|
||||
attachments.collect do |attach_id|
|
||||
ori = Attachment.find_by_id(attach_id)
|
||||
next if ori.blank?
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = obj
|
||||
attach_copied_obj.created_on = Time.now
|
||||
attach_copied_obj.author_id = User.current.id
|
||||
@obj = obj
|
||||
@save_flag = attach_copied_obj.save
|
||||
@save_message = attach_copied_obj.errors.full_messages
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
rescue NoMethodError
|
||||
@save_flag = false
|
||||
@save_message = [] << l(:error_attachment_empty)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
@attachment = Attachment.find(params[:id])
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class AvatarController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
if @temp_file && (@temp_file.size > 0)
|
||||
if @temp_file && (@temp_file.size > 0)
|
||||
diskfile=disk_filename(@source_type,@source_id)
|
||||
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
|
||||
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
|
||||
|
|
@ -55,7 +55,7 @@ class AvatarController < ApplicationController
|
|||
# saved = @avatar.save
|
||||
begin
|
||||
f = Magick::ImageList.new(diskfile)
|
||||
width = 300.0
|
||||
width = 300.0;
|
||||
proportion = (width/f[0].columns)
|
||||
height = (f[0].rows*proportion)
|
||||
f.resize_to_fill!(width,height)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ class BidsController < ApplicationController
|
|||
#Added by young
|
||||
menu_item l(:label_homework), :only => [:edit, :udpate]
|
||||
menu_item :respond
|
||||
menu_item :course, :only => :show_courseEx
|
||||
menu_item :project, :only => [:show_project,:show_results, :new_submit_homework]
|
||||
menu_item :homework_respond, :only => :homework_respond
|
||||
menu_item :homework_statistics, :only => :homework_statistics
|
||||
|
|
@ -451,87 +450,78 @@ class BidsController < ApplicationController
|
|||
# 显示作业课程
|
||||
# add by nwb
|
||||
def show_courseEx
|
||||
if (User.current.logged? && User.current.member_of_course?(@bid.courses.first))
|
||||
# flash[:notice] = ""
|
||||
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
@option = []
|
||||
@membership.each do |membership|
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
@option << membership.course
|
||||
end
|
||||
}
|
||||
# flash[:notice] = ""
|
||||
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
@option = []
|
||||
@membership.each do |membership|
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
@option << membership.course
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@user = @bid.author
|
||||
@bidding_project = @bid.biding_projects.all
|
||||
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@bidding_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||
@temp << pro
|
||||
end
|
||||
end
|
||||
@temp
|
||||
end
|
||||
@bidding_project = @temp
|
||||
else
|
||||
#added by nie
|
||||
@temp = []
|
||||
@bidding_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
@temp << pro
|
||||
end
|
||||
@temp
|
||||
end
|
||||
if @temp.size > 0
|
||||
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||
end
|
||||
#ended
|
||||
end
|
||||
|
||||
@user = @bid.author
|
||||
@bidding_project = @bid.biding_projects.all
|
||||
|
||||
if @bid.homework_type == 1
|
||||
@homework = HomeworkAttach.new
|
||||
#@homework_list = @bid.homeworks
|
||||
#增加作业按评分排序,
|
||||
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@bidding_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||
@temp << pro
|
||||
end
|
||||
end
|
||||
@temp
|
||||
end
|
||||
@bidding_project = @temp
|
||||
else
|
||||
#added by nie
|
||||
@temp = []
|
||||
@bidding_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
@homework_list.each do |pro|
|
||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||
@temp << pro
|
||||
end
|
||||
@temp
|
||||
end
|
||||
if @temp.size > 0
|
||||
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||
end
|
||||
#ended
|
||||
@homework_list = @temp
|
||||
end
|
||||
end
|
||||
|
||||
if @bid.homework_type == 1
|
||||
@homework = HomeworkAttach.new
|
||||
#@homework_list = @bid.homeworks
|
||||
#增加作业按评分排序,
|
||||
#@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
||||
@homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY
|
||||
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC")
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@homework_list.each do |pro|
|
||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||
@temp << pro
|
||||
end
|
||||
@temp
|
||||
end
|
||||
@homework_list = @temp
|
||||
end
|
||||
respond_to do |format|
|
||||
if @bid.reward_type == 3
|
||||
format.html {
|
||||
render :layout => 'base_homework'
|
||||
}
|
||||
elsif @bid.reward_type == 1
|
||||
format.html {
|
||||
render :layout => 'base_bids'
|
||||
}
|
||||
else
|
||||
format.html {
|
||||
render :layout => 'base_contest'
|
||||
}
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @bid.reward_type == 3
|
||||
format.html {
|
||||
render :layout => 'base_homework'
|
||||
}
|
||||
elsif @bid.reward_type == 1
|
||||
format.html {
|
||||
render :layout => 'base_bids'
|
||||
}
|
||||
else
|
||||
format.html {
|
||||
render :layout => 'base_contest'
|
||||
}
|
||||
end
|
||||
format.api
|
||||
end
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -788,7 +778,6 @@ class BidsController < ApplicationController
|
|||
@bid.name = params[:bid][:name]
|
||||
@bid.description = params[:bid][:description]
|
||||
@bid.is_evaluation = params[:bid][:is_evaluation]
|
||||
@bid.proportion = params[:bid][:proportion]
|
||||
@bid.reward_type = 3
|
||||
# @bid.budget = params[:bid][:budget]
|
||||
@bid.deadline = params[:bid][:deadline]
|
||||
|
|
@ -811,10 +800,6 @@ class BidsController < ApplicationController
|
|||
@homework = @bid
|
||||
@course = Course.find_by_id(params[:course_id])
|
||||
@course_id = @course.id
|
||||
#respond_to do |format|
|
||||
# format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'}
|
||||
# format.api { render_validation_errors(@bid) }
|
||||
#end
|
||||
render file: 'courses/new_homework', layout: 'base_courses'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,11 +26,8 @@ class ContestsController < ApplicationController
|
|||
# @contests = Contest.visible
|
||||
# @contests ||= []
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@contests = Contest.visible
|
||||
@contests = Contest.visible
|
||||
@contests = @contests.like(params[:name]) if params[:name].present?
|
||||
if params[:contests_search]
|
||||
(redirect_to contests_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
end
|
||||
@contest_count = @contests.count
|
||||
@contest_pages = Paginator.new @contest_count, @limit, params['page']
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,6 @@ class CoursesController < ApplicationController
|
|||
helper :members
|
||||
helper :words
|
||||
|
||||
menu_item :overview
|
||||
menu_item :feedback, :only => :feedback
|
||||
menu_item :homework, :only => :homework
|
||||
|
||||
menu_item l(:label_sort_by_time), :only => :index
|
||||
menu_item l(:label_sort_by_active), :only => :index
|
||||
menu_item l(:label_sort_by_influence), :only => :index
|
||||
|
|
@ -99,8 +95,7 @@ class CoursesController < ApplicationController
|
|||
# add by nwb
|
||||
def search
|
||||
courses_all = Course.all_course
|
||||
name = params[:name]
|
||||
(redirect_to courses_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
|
||||
@courses = courses_all.visible
|
||||
if params[:name].present?
|
||||
@courses_all = @courses.like(params[:name])
|
||||
|
|
@ -282,11 +277,12 @@ class CoursesController < ApplicationController
|
|||
if @school_id == "0" or @school_id.nil?
|
||||
@courses_all = Course.active.visible.
|
||||
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
||||
where("#{Course.table_name}.course_type = ? ", Course::CourseType_course)
|
||||
else
|
||||
@courses_all = Course.active.visible.
|
||||
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
||||
joins(:course_extra).
|
||||
where("#{Course.table_name}.school_id = ?", @school_id)
|
||||
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id)
|
||||
end
|
||||
|
||||
@course_count = @courses_all.count
|
||||
|
|
@ -407,7 +403,8 @@ class CoursesController < ApplicationController
|
|||
else
|
||||
@courses_all = Course.active.visible.
|
||||
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
||||
where("#{Course.table_name}.school_id = ?", @school_id)
|
||||
joins(:course_extra).
|
||||
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id)
|
||||
end
|
||||
|
||||
@course_count = @courses_all.count
|
||||
|
|
@ -488,10 +485,19 @@ class CoursesController < ApplicationController
|
|||
|
||||
# 新建作业
|
||||
def new_homework
|
||||
@homework = Bid.new
|
||||
@homework.proportion
|
||||
@homework.safe_attributes = params[:bid]
|
||||
if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] ))
|
||||
if (User.current.logged? &&
|
||||
(User.current.admin? ||
|
||||
(
|
||||
!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? &&
|
||||
(
|
||||
Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles &&
|
||||
( Role.where(id: [3, 4, 7, 9]).size > 0 )
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@homework = Bid.new
|
||||
@homework.safe_attributes = params[:bid]
|
||||
render :layout => 'base_courses'
|
||||
else
|
||||
render_404
|
||||
|
|
@ -546,47 +552,22 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def get_courses
|
||||
@user = User.current
|
||||
membership = @user.coursememberships.all
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
@memberships = []
|
||||
membership.collect { |e|
|
||||
@memberships.push(e)
|
||||
}
|
||||
@memberships_doing = []
|
||||
@memberships_done = []
|
||||
now_time = Time.now.year
|
||||
@memberships.map { |e|
|
||||
end_time = e.course.get_time.year
|
||||
isDone = course_endTime_timeout?(e.course)
|
||||
if isDone
|
||||
@memberships_done.push e
|
||||
else
|
||||
@memberships_doing.push e
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def finishcourse
|
||||
yesterday = Date.today.prev_day.to_time
|
||||
|
||||
@course_prefs.endup_time = yesterday
|
||||
@save_flag = @course_prefs.save
|
||||
get_courses
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def restartcourse
|
||||
day = Time.parse("3000-01-01")
|
||||
|
||||
@course_prefs.endup_time = day
|
||||
@save_flag = @course_prefs.save
|
||||
get_courses
|
||||
|
||||
respond_to do |format|
|
||||
format.js {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,6 @@ class ForumsController < ApplicationController
|
|||
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
|
||||
format.json { render json: @forum, status: :created, location: @forum }
|
||||
else
|
||||
flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}"
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @forum.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
|
@ -166,8 +165,6 @@ class ForumsController < ApplicationController
|
|||
|
||||
def search_forum
|
||||
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
name = params[:name]
|
||||
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
@forums_count = @forums_all.count
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class HomeworkAttachController < ApplicationController
|
||||
include CoursesHelper
|
||||
###############################
|
||||
#判断当前角色权限时需先找到当前操作的project
|
||||
before_filter :find_course_by_bid_id, :only => [:new]
|
||||
|
|
@ -78,15 +77,6 @@ class HomeworkAttachController < ApplicationController
|
|||
if bid.homeworks.where("user_id = ?",User.current).count == 0
|
||||
user_id = params[:user_id]
|
||||
bid_id = params[:bid_id]
|
||||
if params[:homework_attach]
|
||||
if params[:homework_attach][:project_id]
|
||||
project_id = params[:homework_attach][:project_id]
|
||||
else
|
||||
project_id = 0
|
||||
end
|
||||
else
|
||||
project_id = 0
|
||||
end
|
||||
sta = 0
|
||||
name = params[:new_form][:name]
|
||||
description = params[:new_form][:description]
|
||||
|
|
@ -95,8 +85,7 @@ class HomeworkAttachController < ApplicationController
|
|||
:state => sta,
|
||||
:name => name,
|
||||
:description => description,
|
||||
:bid_id => bid_id,
|
||||
:project_id => project_id
|
||||
:bid_id => bid_id
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -188,18 +177,8 @@ class HomeworkAttachController < ApplicationController
|
|||
if User.current.admin? || User.current.member_of_course?(course)
|
||||
name = params[:homework_name]
|
||||
description = params[:homework_description]
|
||||
if params[:homework_attach]
|
||||
if params[:homework_attach][:project_id]
|
||||
project_id = params[:homework_attach][:project_id]
|
||||
else
|
||||
project_id = 0
|
||||
end
|
||||
else
|
||||
project_id = 0
|
||||
end
|
||||
@homework.name = name
|
||||
@homework.description = description
|
||||
@homework.project_id = project_id
|
||||
if params[:attachments]
|
||||
@homework.save_attachments(params[:attachments])
|
||||
end
|
||||
|
|
@ -258,9 +237,6 @@ class HomeworkAttachController < ApplicationController
|
|||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
|
||||
|
||||
@totle_score = score_for_homework @homework
|
||||
@teaher_score = teacher_score_for_homework @homework
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
|
|
@ -292,24 +268,11 @@ class HomeworkAttachController < ApplicationController
|
|||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
|
||||
|
||||
@totle_score = score_for_homework @homework
|
||||
@teaher_score = teacher_score_for_homework @homework
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#教师综评
|
||||
def comprehensive_evaluation_jour
|
||||
@homework = HomeworkAttach.find(params[:jour_id])
|
||||
@add_jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,params[:is_comprehensive_evaluation]
|
||||
respond_to do |format|
|
||||
format.html { redirect_to homework_attach_path @homework }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
#获取指定作业的平均得分
|
||||
def score
|
||||
#stars_reates = @homework.rates(:quality)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class MembersController < ApplicationController
|
|||
user_ids = attrs.delete(:user_ids)
|
||||
user_ids.each do |user_id|
|
||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||
#user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id)
|
||||
user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id)
|
||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||
course_info << CourseInfo.new(:user_id => user_id, :course_id => @course.id)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,10 +51,7 @@ class MemosController < ApplicationController
|
|||
|
||||
@memo_new = @memo.dup
|
||||
@memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
||||
unless @memo.new_record?
|
||||
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
|
||||
end
|
||||
|
||||
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
|
||||
|
||||
page = params[:page]
|
||||
if params[:r] && page.nil?
|
||||
|
|
@ -71,14 +68,10 @@ class MemosController < ApplicationController
|
|||
limit(@reply_pages.per_page).
|
||||
offset(@reply_pages.offset).
|
||||
all
|
||||
if @memo.new_record?
|
||||
format.html { redirect_to back_url, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
|
||||
else
|
||||
format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
|
||||
# format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
|
||||
format.json { render json: @memo.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
||||
format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
|
||||
# format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
|
||||
format.json { render json: @memo.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -68,9 +68,6 @@ class MessagesController < ApplicationController
|
|||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
redirect_to board_message_path(@board, @message)
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :action => 'new', :layout => layout_file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -87,11 +84,8 @@ class MessagesController < ApplicationController
|
|||
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
|
||||
redirect_to board_message_path(@board, @topic, :r => @reply)
|
||||
|
||||
end
|
||||
|
||||
# Edit a message
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class MyController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
@se = @user.extensions
|
||||
@se = @user.user_extensions ||= UserExtensions.new
|
||||
@se.school_id = params[:occupation] if params[:occupation]
|
||||
@se.gender = params[:gender]
|
||||
@se.location = params[:province] if params[:province]
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class NewsController < ApplicationController
|
|||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to project_news_index_path(@project)
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
|
||||
render :action => 'new', :layout => layout_file
|
||||
end
|
||||
elsif @course
|
||||
|
|
|
|||
|
|
@ -9,12 +9,9 @@ class PraiseTreadController < ApplicationController
|
|||
if request.get?
|
||||
@obj_id = params[:obj_id]
|
||||
@obj_type = params[:obj_type]
|
||||
@horizontal = params[:horizontal].downcase == "false" ? false:true
|
||||
@horizontal = params[:horizontal]
|
||||
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
|
||||
unless @obj.author_id == User.current.id
|
||||
praise_tread_plus(@obj_type,@obj_id,1)
|
||||
end
|
||||
|
||||
praise_tread_plus(@obj_type,@obj_id,1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -48,12 +45,9 @@ class PraiseTreadController < ApplicationController
|
|||
if request.get?
|
||||
@obj_id = params[:obj_id]
|
||||
@obj_type = params[:obj_type]
|
||||
@horizontal = params[:horizontal].downcase == "false" ? false:true
|
||||
@horizontal = params[:horizontal]
|
||||
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
|
||||
unless @obj.author_id == User.current.id
|
||||
praise_tread_plus(@obj_type,@obj_id,0)
|
||||
end
|
||||
|
||||
praise_tread_plus(@obj_type,@obj_id,0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class ProjectsController < ApplicationController
|
|||
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
||||
before_filter :file, :statistics, :watcherlist
|
||||
before_filter :find_project_repository, :only => [:show]
|
||||
|
||||
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
|
||||
before_filter :memberAccess, only: :member
|
||||
|
||||
|
|
@ -78,14 +78,6 @@ class ProjectsController < ApplicationController
|
|||
### added by william
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
|
||||
def find_project_repository
|
||||
unless @project.repositories.nil?
|
||||
@project.repositories.each do |repository|
|
||||
repository.fetch_changesets if Setting.autofetch_changesets?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def enterprise_course
|
||||
session[:enterprise_college] = 2
|
||||
respond_to do |format|
|
||||
|
|
@ -364,10 +356,19 @@ class ProjectsController < ApplicationController
|
|||
#Added by young
|
||||
def homework
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@bids = @project.homeworks.order('deadline')
|
||||
@bids = @project.homeworks.order('deadline DESC')
|
||||
@bids = @bids.like(params[:name]) if params[:name].present?
|
||||
@bid_count = @bids.count
|
||||
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
||||
|
||||
@bids = paginateHelper @bids
|
||||
@offset ||= @bid_pages.reverse_offset
|
||||
#@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
||||
unless @offset == 0
|
||||
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @bid_count % @limit
|
||||
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
render :layout => 'base_courses'
|
||||
|
||||
end
|
||||
|
|
@ -914,13 +915,11 @@ class ProjectsController < ApplicationController
|
|||
|
||||
# added by bai
|
||||
def show_projects_score
|
||||
render :layout => false
|
||||
|
||||
end
|
||||
|
||||
def issue_score_index
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def news_score_index
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ class RepositoriesController < ApplicationController
|
|||
project = Project.find(params[:id])
|
||||
if !User.current.member_of?(project)
|
||||
if project.hidden_repo
|
||||
#render_403
|
||||
render_403
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class SchoolController < ApplicationController
|
|||
end
|
||||
options = ""
|
||||
@school.each do |s|
|
||||
options << "<li style = 'width: 33%; float: left'> <a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
|
||||
options << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
|
|
|||
|
|
@ -64,18 +64,15 @@ class TagsController < ApplicationController
|
|||
@forum_tags_num, @attachments_tags_num, @open_source_projects_num = get_tags_size
|
||||
|
||||
# 获取搜索结果
|
||||
@obj,
|
||||
@obj_pages,
|
||||
@results_count,
|
||||
@users_results,
|
||||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@@courses_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_tags,
|
||||
@open_source_projects_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
|
||||
# 这里是做tag推荐用的, 用来生产推荐的tags
|
||||
unless @obj.nil?
|
||||
|
|
@ -100,18 +97,14 @@ class TagsController < ApplicationController
|
|||
$related_tags.delete(@tag)
|
||||
|
||||
# 获取搜索结果
|
||||
@obj,
|
||||
@obj_pages,
|
||||
@results_count,
|
||||
@users_results,
|
||||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@@courses_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results= refresh_results(@obj_id,@show_flag)
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results = refresh_results(@obj_id,@show_flag)
|
||||
end
|
||||
|
||||
# 删除已选tag
|
||||
|
|
@ -123,18 +116,14 @@ class TagsController < ApplicationController
|
|||
$selected_tags.delete(@tag)
|
||||
|
||||
# 获取搜索结果
|
||||
@obj,
|
||||
@obj_pages,
|
||||
@results_count,
|
||||
@users_results,
|
||||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@@courses_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@contests_results,
|
||||
@courses_results,
|
||||
@open_source_projects_results= refresh_results(@obj_id,@show_flag)
|
||||
@attachments_results,
|
||||
@contests_results = refresh_results(@obj_id,@show_flag)
|
||||
end
|
||||
|
||||
def show_all
|
||||
|
|
@ -267,14 +256,14 @@ class TagsController < ApplicationController
|
|||
|
||||
# 获取有某类对象的tag总数
|
||||
def get_tags_size
|
||||
@issues_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Issue").count
|
||||
@projects_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Project").count
|
||||
@users_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"User").count
|
||||
@bids_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Bid").count
|
||||
forum_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Forum").count
|
||||
attachment_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Attachment").count
|
||||
@open_source_projects_num = ActsAsTaggableOn::Tagging.where(taggable_type:"OpenSourceProject").count
|
||||
@contests_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Contest").count
|
||||
@issues_tags_num = Issue.tag_counts.size
|
||||
@projects_tags_num = Project.tag_counts.size
|
||||
@users_tags_num = User.tag_counts.size
|
||||
@bids_tags_num = Bid.tag_counts.size
|
||||
forum_tags_num = Forum.tag_counts.size
|
||||
attachment_tags_num = Attachment.tag_counts.size
|
||||
@open_source_projects_num = OpenSourceProject.tag_counts.size
|
||||
@contests_tags_num = Contest.tag_counts.size
|
||||
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num, @open_source_projects_num
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -32,14 +32,12 @@ class UsersController < ApplicationController
|
|||
|
||||
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
|
||||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score]
|
||||
:activity_score_index, :influence_score_index, :score_index]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
:watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index]
|
||||
:activity_score_index, :influence_score_index, :score_index]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
|
||||
|
||||
|
|
@ -52,7 +50,6 @@ class UsersController < ApplicationController
|
|||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
include AvatarHelper
|
||||
include WordsHelper
|
||||
|
||||
# added by liuping 关注
|
||||
|
||||
|
|
@ -95,11 +92,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# added by bai
|
||||
def show_score
|
||||
|
||||
end
|
||||
|
||||
def show_new_score
|
||||
render :layout => false
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
|
|
@ -236,10 +229,7 @@ class UsersController < ApplicationController
|
|||
def user_newfeedback
|
||||
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@jours.update_all(:is_readed => true, :status => false)
|
||||
@jours.each do |journal|
|
||||
fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
|
||||
end
|
||||
|
||||
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
|
|
@ -373,7 +363,7 @@ class UsersController < ApplicationController
|
|||
def search
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
(redirect_to users_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit({:limit => 15})
|
||||
|
|
@ -781,30 +771,7 @@ class UsersController < ApplicationController
|
|||
|
||||
end
|
||||
# end
|
||||
def topic_new_score_index
|
||||
|
||||
end
|
||||
|
||||
def project_new_score_index
|
||||
|
||||
end
|
||||
|
||||
def activity_new_score_index
|
||||
|
||||
end
|
||||
|
||||
def influence_new_score_index
|
||||
|
||||
end
|
||||
|
||||
def score_new_index
|
||||
|
||||
end
|
||||
|
||||
def update_score
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def find_user
|
||||
|
|
|
|||
|
|
@ -30,11 +30,6 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
def course
|
||||
if params[:school_id]
|
||||
@school_id = params[:school_id]
|
||||
elsif User.current.logged? && User.current.user_extensions.school
|
||||
@school_id = User.current.user_extensions.school.try(:id)
|
||||
end
|
||||
@logoLink ||= logolink()
|
||||
end
|
||||
|
||||
|
|
@ -80,7 +75,8 @@ class WelcomeController < ApplicationController
|
|||
redirect_to projects_search_path(:name => search_condition,
|
||||
:project_type => Project::ProjectType_project)
|
||||
when :courses
|
||||
redirect_to courses_search_path(:name => search_condition)
|
||||
redirect_to projects_search_path(:name => search_condition,
|
||||
:project_type => Project::ProjectType_course)
|
||||
when :users
|
||||
redirect_to users_search_path(:name => search_condition)
|
||||
when :users_teacher
|
||||
|
|
@ -88,8 +84,7 @@ class WelcomeController < ApplicationController
|
|||
when :users_student
|
||||
redirect_to users_search_path(:name => search_condition, :role => :student)
|
||||
else
|
||||
#redirect_to home_path, :alert => l(:label_sumbit_empty)
|
||||
(redirect_to home_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank?
|
||||
redirect_to home_path, :alert => l(:label_sumbit_empty)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ class WordsController < ApplicationController
|
|||
reply_user_id = params[:reference_user_id]
|
||||
reply_id = params[:reference_message_id] # 暂时不实现
|
||||
content = params[:user_notes]
|
||||
options = {:user_id => author_id,
|
||||
:status => true,
|
||||
options = {:user_id => author_id,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class ZipdownController < ApplicationController
|
|||
else
|
||||
logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!"
|
||||
end
|
||||
send_file zipfile, :filename => obj.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
||||
send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile
|
||||
|
||||
#rescue NameError, ActiveRecord::RecordNotFound => e
|
||||
#logger.error "[ZipDown] ===> #{e}"
|
||||
|
|
@ -39,7 +39,7 @@ class ZipdownController < ApplicationController
|
|||
homework = HomeworkAttach.find params[:homework]
|
||||
if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first))
|
||||
zipfile = zip_homework_by_user homework
|
||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
||||
send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile
|
||||
else
|
||||
render_403 :message => :notice_not_authorized
|
||||
end
|
||||
|
|
@ -88,7 +88,7 @@ class ZipdownController < ApplicationController
|
|||
#length = attach.storage_path.length
|
||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||
end
|
||||
zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
||||
zipping "#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
||||
#user_attaches_paths
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ module ApplicationHelper
|
|||
# REVIEW: 目测menu的机制,貌似不是很需要转换,再说
|
||||
def link_class(label)
|
||||
labels = label.is_a?(Array) ? label : ([] << label)
|
||||
#a = current_menu_item
|
||||
labels.include?(current_menu_item) ? 'selected' : ''
|
||||
|
||||
end
|
||||
#Ended by young
|
||||
# Return true if user is authorized for controller/action, otherwise false
|
||||
|
|
@ -473,11 +471,7 @@ module ApplicationHelper
|
|||
def principals_check_box_tags_ex(name, principals)
|
||||
s = ''
|
||||
principals.each do |principal|
|
||||
if principal.has_attribute?(:userInfo)
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
else
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
|
||||
end
|
||||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal.userInfo }</label>\n"
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ module AttachmentsHelper
|
|||
|
||||
s = content_tag('div', attachments_check_box_tags('attachment[attach][]', searched_attach), :id => 'attachments')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
|
||||
link_to text, attachments_autocomplete_path( parameters.merge(:project_id=>project.id,:q => params[:q], :format => 'js')), :remote => true }
|
||||
link_to text, attachments_autocomplete_path( parameters.merge(:q => params[:q], :format => 'js')), :remote => true }
|
||||
|
||||
return s + content_tag('div', content_tag('ul', links), :class => 'pagination')
|
||||
|
||||
|
|
@ -133,35 +133,6 @@ module AttachmentsHelper
|
|||
# return searched_attach.to_json
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
def render_attachments_for_new_course(course, limit=nil)
|
||||
# 查询条件
|
||||
params[:q] ||= ""
|
||||
filename_condition = params[:q].strip
|
||||
|
||||
attachAll = Attachment.scoped
|
||||
|
||||
# 除去当前课程的所有资源
|
||||
nobelong_attach = Attachment.where("!(container_type = '#{course.class}' and container_id = #{course.id})") unless course.blank?
|
||||
|
||||
# 搜索域确定
|
||||
domain = course.nil? ? attachAll : nobelong_attach
|
||||
|
||||
# 搜索到的资源
|
||||
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
||||
searched_attach = private_filter searched_attach
|
||||
searched_attach = paginateHelper(searched_attach, 10)
|
||||
|
||||
#testattach = Attachment.public_attachments
|
||||
|
||||
s = content_tag('div', attachments_check_box_tags('attachment[attach][]', searched_attach), :id => 'attachments')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
|
||||
link_to text, attachments_autocomplete_path( parameters.merge(:course_id=>course.id,:q => params[:q], :format => 'js')), :remote => true }
|
||||
|
||||
return s + content_tag('div', content_tag('ul', links), :class => 'pagination')
|
||||
|
||||
end
|
||||
|
||||
def attachments_check_box_tags(name, attachs)
|
||||
s = ''
|
||||
attachs.each do |attach|
|
||||
|
|
@ -173,22 +144,18 @@ module AttachmentsHelper
|
|||
def private_filter resultSet
|
||||
result = resultSet.to_a.dup
|
||||
|
||||
# modify by nwb
|
||||
#添加对课程资源文件的判断
|
||||
resultSet.map { |res|
|
||||
if(res.container.nil? ||
|
||||
(res.container.class.to_s=="Project" && res.container.is_public == false) ||
|
||||
(res.container.has_attribute?(:project) && res.container.project && res.container.project.is_public == false) ||
|
||||
(res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
|
||||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
|
||||
(res.container.class.to_s=="Course" && res.container.is_public == false) ||
|
||||
(res.container.has_attribute?(:course) && res.container.course && res.container.course.is_public == false)
|
||||
false
|
||||
)
|
||||
result.delete(res)
|
||||
end
|
||||
}
|
||||
result
|
||||
end
|
||||
|
||||
include Redmine::Pagination
|
||||
def paginateHelper obj, pre_size=10
|
||||
@obj_count = obj.count
|
||||
|
|
|
|||
|
|
@ -1,184 +0,0 @@
|
|||
#enconding:utf-8
|
||||
# fq
|
||||
module BidsHelper
|
||||
|
||||
def render_notes(bid, journal, options={})
|
||||
content = ''
|
||||
removable = User.current == journal.user || User.current == bid.author
|
||||
links = []
|
||||
if !journal.notes.blank?
|
||||
links << link_to(image_tag('comment.png'),
|
||||
{:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal},
|
||||
:remote => true,
|
||||
:method => 'post',
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
if removable
|
||||
url = {:controller => 'bids',
|
||||
:action => 'destroy',
|
||||
:object_id => journal,
|
||||
:id => bid}
|
||||
links << ' '
|
||||
links << link_to(image_tag('delete.png'), url,
|
||||
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
|
||||
end
|
||||
end
|
||||
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||
content << textilizable(journal.notes)
|
||||
css_classes = "wiki"
|
||||
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={})
|
||||
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
||||
link_to text, '#', options.merge(:onclick => onclick)
|
||||
end
|
||||
|
||||
# this method is used to get all projects that tagged one tag
|
||||
# added by william
|
||||
def get_bids_by_tag(tag_name)
|
||||
Bid.tagged_with(tag_name).order('updated_on desc')
|
||||
end
|
||||
|
||||
#added by huang
|
||||
def sort_bid_enterprise(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs_enterprise")
|
||||
end
|
||||
#end
|
||||
|
||||
def sort_bid(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
|
||||
#huang
|
||||
def sort_contest(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1')))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0')))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
#end
|
||||
|
||||
def course_options_for_select(courses)
|
||||
# <option value = '0'>#{l(:label_choose_reward)}</option>
|
||||
html = ''
|
||||
courses.each do |course|
|
||||
html << "<option value = #{course.id}>"
|
||||
html << course.name
|
||||
html << "</option>"
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
# used to get the reward and handle the value which can be used to display in views
|
||||
# added by william
|
||||
def get_prize(b_project)
|
||||
b_project.get_reward
|
||||
end
|
||||
|
||||
def count_bid_project
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@projects = []
|
||||
for bid in bids
|
||||
@projects += bid.biding_projects
|
||||
end
|
||||
@projects.count
|
||||
end
|
||||
|
||||
def count_bid_user
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@users = []
|
||||
for bid in bids
|
||||
for project in bid.projects
|
||||
@users += project.users
|
||||
end
|
||||
end
|
||||
@users.count
|
||||
end
|
||||
|
||||
# 查看学号
|
||||
def im_watching_student_id? bid
|
||||
people = []
|
||||
people << bid.author
|
||||
case bid.reward_type # 天煞的bid分了三用途,里面各种hasmany还不定能用!
|
||||
when Bid::Enterprise
|
||||
when Bid::Contest
|
||||
bid.join_in_contests.each do |jic|
|
||||
people << jic.user
|
||||
end
|
||||
when Bid::Homework
|
||||
# people += bid.courses.first.users.to_a
|
||||
people += searchTeacherAndAssistant(bid.courses.first).to_a
|
||||
else
|
||||
raise 'bids_helper: unknow bid type' # 出了错看这里!不知道的抛异常,省的找不到出错的地方!
|
||||
end
|
||||
people.include?(User.current)
|
||||
end
|
||||
|
||||
# 当前用户是否加入了此课程(包括教师)
|
||||
def is_cur_course_user? bid
|
||||
people = []
|
||||
#people << bid.author
|
||||
course = bid.courses.first
|
||||
course.members.each do |member|
|
||||
people << member.user
|
||||
end
|
||||
people.include?(User.current)
|
||||
end
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#当前用户是不是指定课程的学生
|
||||
def is_cur_course_student? course
|
||||
people = []
|
||||
course.members.each do |member|
|
||||
if [5,10].include? member.roles.first.id
|
||||
people << member.user
|
||||
end
|
||||
end
|
||||
people.include?(User.current)
|
||||
end
|
||||
>>>>>>> 8c33cf0afb89556112710759615cbd88bb0326f2
|
||||
|
||||
# def select_option_helper option
|
||||
# tmp = Hash.new
|
||||
# option.each do |project|
|
||||
# tmp[project.name] = project.identifier
|
||||
# end
|
||||
# tmp
|
||||
# end
|
||||
|
||||
def can_delete_project_homework bind_project,current_user
|
||||
current_user.id == bind_project.user.id || current_user.admin
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -83,19 +83,6 @@ module CoursesHelper
|
|||
type << option2
|
||||
end
|
||||
|
||||
def proportion_option
|
||||
type = []
|
||||
i = 0
|
||||
while i <= 100
|
||||
option = []
|
||||
option << i.to_s + "%"
|
||||
option << i
|
||||
type << option
|
||||
i = i + 10
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
|
||||
alias teacherCountOrigin teacherCount
|
||||
def teacherCount project
|
||||
|
|
@ -256,8 +243,8 @@ module CoursesHelper
|
|||
people
|
||||
end
|
||||
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
|
||||
def course_endTime_timeout? course
|
||||
end_time_str = course.try(:endup_time)
|
||||
def course_endTime_timeout? project
|
||||
end_time_str = Course.find_by_extra(project.try(:extra)).try(:endup_time)
|
||||
begin
|
||||
cTime = Time.parse(end_time_str.to_s)
|
||||
rescue TypeError,ArgumentError
|
||||
|
|
@ -316,76 +303,4 @@ module CoursesHelper
|
|||
def users_for_homework homework
|
||||
homework.nil? ? [] : (homework.users + [homework.user])
|
||||
end
|
||||
|
||||
#获取指定作业的最终评分
|
||||
#最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6
|
||||
def score_for_homework homework
|
||||
if homework.bid.is_evaluation == 1 || homework.bid.is_evaluation == nil
|
||||
return format("%.2f",(homework.bid.proportion * 1.0 / 100) * (teacher_score_for_homework(homework).to_f) + (1 - homework.bid.proportion * 1.0 / 100) * (student_score_for_homework(homework).to_f))
|
||||
else
|
||||
return teacher_score_for_homework homework
|
||||
end
|
||||
end
|
||||
|
||||
#获取作业的互评得分
|
||||
def student_score_for_homework homework
|
||||
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
|
||||
student_stars_count = 0
|
||||
student_stars.each do |star|
|
||||
student_stars_count = student_stars_count + star.stars
|
||||
end
|
||||
return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count))
|
||||
end
|
||||
|
||||
#获取作业的教师评分
|
||||
def teacher_score_for_homework homework
|
||||
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first
|
||||
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars)
|
||||
end
|
||||
|
||||
#获取指定项目的得分
|
||||
def project_score project
|
||||
issue_count = project.issues.count
|
||||
issue_journal_count = project.issue_changes.count
|
||||
issue_score = issue_count * 0.2
|
||||
issue_journal_score = issue_journal_count * 0.1
|
||||
finall_issue_score = issue_score + issue_journal_score
|
||||
new_count = project.news.count
|
||||
new_score = new_count * 0.1
|
||||
finall_new_score = new_score
|
||||
document_count = project.documents.count
|
||||
file_score = document_count * 0.1
|
||||
finall_file_score = file_score
|
||||
changeset_count = project.changesets.count
|
||||
code_submit_score = changeset_count * 0.3
|
||||
finall_code_submit_score = code_submit_score
|
||||
board_message_count = 0
|
||||
project.boards.each do |board|
|
||||
board_message_count += board.messages_count
|
||||
end
|
||||
topic_score = board_message_count * 0.1
|
||||
#finall_topic_score = topic_score
|
||||
finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score
|
||||
format("%.2f",finall_project_score)
|
||||
end
|
||||
|
||||
#获取指定作业的参与人员
|
||||
#返回结果:张三、李四、王五
|
||||
def homework_user_of_homework homework,is_teacher
|
||||
homework_users = ""
|
||||
homework.users.each do |user|
|
||||
homework_users = homework_users + (is_teacher ? user.realname : user.name)
|
||||
if user != homework.users.last
|
||||
homework_users = homework_users + "、"
|
||||
end
|
||||
end
|
||||
return homework_users
|
||||
end
|
||||
|
||||
def get_courses_by_tag(tag_name)
|
||||
Course.tagged_with(tag_name).order('updated_at desc')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -54,24 +54,4 @@ module HomeworkAttachHelper
|
|||
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
end
|
||||
end
|
||||
|
||||
def user_projects_option
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
memberships = User.current.memberships.all(:conditions => cond)
|
||||
projects = memberships.map(&:project)
|
||||
not_have_project = []
|
||||
not_have_project << "<<NULL>>"
|
||||
not_have_project << 0
|
||||
type = []
|
||||
type << not_have_project
|
||||
projects.each do |project|
|
||||
if project != nil
|
||||
option = []
|
||||
option << project.name
|
||||
option << project.id
|
||||
type << option
|
||||
end
|
||||
end
|
||||
type
|
||||
end
|
||||
end
|
||||
|
|
@ -70,7 +70,7 @@ module JournalsHelper
|
|||
content << textilizable(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:580px")
|
||||
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={})
|
||||
|
|
|
|||
|
|
@ -247,15 +247,4 @@ module UsersHelper
|
|||
displayed_flag = %w|index|
|
||||
!displayed_flag.include?(params['action'])
|
||||
end
|
||||
|
||||
#获取指定用户的未过期的课程列表
|
||||
def user_courses_list user
|
||||
result = []
|
||||
user.coursememberships.map(&:course).each do |course|
|
||||
if !course_endTime_timeout?(course)
|
||||
result << course
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,30 +67,6 @@ module WatchersHelper
|
|||
|
||||
link_to text, url, :remote => true, :method => method, :class => css
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 关注课程
|
||||
def new_course_watcher_link(objects, user, options=[])
|
||||
return '' unless user && user.logged?
|
||||
objects = Array.wrap(objects)
|
||||
|
||||
watched = objects.any? {|object| object.watched_by?(user)}
|
||||
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest)))
|
||||
css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
|
||||
([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
|
||||
|
||||
text = @watch_flag ?
|
||||
(watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
|
||||
|
||||
url = watch_path(
|
||||
:object_type => objects.first.class.to_s.underscore,
|
||||
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
|
||||
)
|
||||
method = watched ? 'delete' : 'post'
|
||||
|
||||
link_to text, url, :remote => true, :method => method, :class => css
|
||||
end
|
||||
|
||||
# added by fq, modify nyan
|
||||
# Somebody may use option params
|
||||
def join_in_course(course, user, options=[])
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ module WelcomeHelper
|
|||
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
||||
#
|
||||
# Returns project&courses array
|
||||
# 原来的取课程逻辑
|
||||
def find_miracle_course_base(sum=10, max_rate=7, school_id)
|
||||
def find_miracle_course(sum=10, max_rate=7, school_id)
|
||||
|
||||
if User.current.user_extensions.school.nil? and school_id.nil?
|
||||
Project.active.visible.course_entities.
|
||||
|
|
@ -134,51 +133,6 @@ module WelcomeHelper
|
|||
# (c1.take(max)+c2).take(sum)
|
||||
end
|
||||
|
||||
#获取课程列表
|
||||
# add by nwb
|
||||
def find_miracle_course(sum=10, max_rate=7, school_id)
|
||||
if User.current.user_extensions.school.nil? and school_id.nil?
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
group('members.course_id').
|
||||
reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
|
||||
else
|
||||
if school_id.nil?
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id).
|
||||
group('members.course_id').
|
||||
reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
|
||||
else
|
||||
if school_id == "0"
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
group('members.course_id').
|
||||
reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
|
||||
else
|
||||
Course.active.visible.
|
||||
joins(:memberships).
|
||||
where("#{Course.table_name}.school_id = ?", school_id).
|
||||
group('members.course_id').
|
||||
reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
|
||||
end
|
||||
end
|
||||
end
|
||||
# else
|
||||
# Project.active.visible.course_entities.
|
||||
# joins(:course_extra).
|
||||
# joins(:memberships).
|
||||
# where("#{Course.table_name}.school_id = ?", school_id).
|
||||
# group('members.project_id').
|
||||
# reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
||||
# end
|
||||
# max = sum*(max_rate.to_f/10)
|
||||
# c1 = find_new_course(sum).to_a.dup
|
||||
# c2 = find_all_hot_course(sum).to_a.dup
|
||||
# c2 = c2 - c1
|
||||
# (c1.take(max)+c2).take(sum)
|
||||
end
|
||||
|
||||
#查找所有学校按每个学校开设课程数量降序排序
|
||||
#page 分页查询开始条数的编号,从0开始
|
||||
#limit 分页查询的数量
|
||||
|
|
@ -204,11 +158,10 @@ module WelcomeHelper
|
|||
end
|
||||
|
||||
def find_miracle_project(sum, max_rate)
|
||||
#max = sum*(max_rate.to_f/10)
|
||||
#c1 = find_new_project(sum).to_a.dup
|
||||
#c2 = find_all_hot_project(sum).to_a.dup
|
||||
#(c2.take(sum-max)+c1.take(max)).take(sum)
|
||||
find_all_hot_project(sum).to_a.dup
|
||||
max = sum*(max_rate.to_f/10)
|
||||
c1 = find_new_project(sum).to_a.dup
|
||||
c2 = find_all_hot_project(sum).to_a.dup
|
||||
(c2.take(sum-max)+c1.take(max)).take(sum)
|
||||
end
|
||||
|
||||
def find_new_course limit=15
|
||||
|
|
@ -228,18 +181,11 @@ module WelcomeHelper
|
|||
sort_course_by_hot limit
|
||||
end
|
||||
|
||||
# modif by nwb
|
||||
def find_all_new_hot_course limit = 9 ,school_id = 0
|
||||
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
|
||||
time_now = Time.new.strftime("%Y");
|
||||
if school_id
|
||||
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
|
||||
?", school_id).order("course_ac_para DESC").limit(limit).all
|
||||
else
|
||||
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
|
||||
").order("course_ac_para DESC").limit(limit).all
|
||||
end
|
||||
courses
|
||||
Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ? and #{Project.table_name}.created_on like '%#{time_now}%' and #{Project.table_name}.identifier not in
|
||||
(select extra from courses where school_id = ?)", 1,school_id).order("course_ac_para DESC").limit(limit).all
|
||||
end
|
||||
|
||||
def find_all_hot_bid
|
||||
|
|
@ -288,7 +234,6 @@ module WelcomeHelper
|
|||
def show_grade project
|
||||
grade = 0
|
||||
begin
|
||||
#ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();")#执行存储过程速度慢
|
||||
grade = project.project_status.grade if project && project.project_status
|
||||
rescue Exception => e
|
||||
logger.error "Logger.Error [WelcomeHelper] ===> #{e}"
|
||||
|
|
@ -387,7 +332,7 @@ module WelcomeHelper
|
|||
end
|
||||
|
||||
#取得所有活动
|
||||
def find_all_activities limit=6
|
||||
def find_all_activities limit=6
|
||||
# users = []
|
||||
# activities = Activity.find_by_sql("select distinct user_id from activities order by id DESC limit #{limit}" )
|
||||
# activities.each { |activity|
|
||||
|
|
|
|||
|
|
@ -68,106 +68,6 @@ class Attachment < ActiveRecord::Base
|
|||
before_save :be_user_score # user_score
|
||||
after_destroy :delete_from_disk
|
||||
|
||||
# add by nwb
|
||||
# 获取所有可公开的资源文件列表
|
||||
scope :public_attachments, lambda {
|
||||
#joins(Project.table_name).where("container_type = 'Project' and ")
|
||||
joins("LEFT JOIN #{Project.table_name} ON #{Attachment.table_name}.container_type='Project' AND #{Project.table_name}.id = #{Attachment.table_name}.container_id and #{Project.table_name}.is_public=1 " +
|
||||
" LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Project' AND #{Document.table_name}.project_id in "+self.public_project_id +
|
||||
" LEFT JOIN #{Issue.table_name} ON #{Attachment.table_name}.container_type='Project' AND #{Issue.table_name}.project_id in "+self.public_project_id +
|
||||
" LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Project' AND #{Version.table_name}.project_id in "+self.public_project_id +
|
||||
" LEFT JOIN #{WikiPage.table_name} ON #{Attachment.table_name}.container_type='WikiPage' AND #{WikiPage.table_name}.parent_id in "+self.public_wiki_id +
|
||||
" LEFT JOIN #{Message.table_name} ON #{Attachment.table_name}.container_type='Message' AND #{Message.table_name}.parent_id in "+self.public_board_id +
|
||||
" LEFT JOIN #{Course.table_name} ON #{Attachment.table_name}.container_type='Course' AND #{Course.table_name}.is_public=1 " +
|
||||
" LEFT JOIN #{News.table_name} ON #{Attachment.table_name}.container_type='News' AND (#{News.table_name}.project_id in "+self.public_project_id + " OR #{News.table_name}.course_id in " + self.public_course_id + ")" +
|
||||
" LEFT JOIN #{HomeworkAttach.table_name} ON #{Attachment.table_name}.container_type='HomeworkAttach' AND #{HomeworkAttach.table_name}.bid_id in "+self.public_bid_id)
|
||||
}
|
||||
|
||||
# add by nwb
|
||||
# 公开的项目id列表
|
||||
def self.public_project_id
|
||||
idlist = "("
|
||||
projects=Project.all_public
|
||||
count = projects.count
|
||||
for i in 0...count
|
||||
project = projects[i]
|
||||
idlist+="'" + project.id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist+=","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
idlist
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 公开的课程id列表
|
||||
def self.public_course_id
|
||||
idlist = "("
|
||||
courses=Course.all_public
|
||||
count = courses.count
|
||||
for i in 0...count
|
||||
course = courses[i]
|
||||
idlist+="'" + course.id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist = idlist + ","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
idlist
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 公开的wiki id列表
|
||||
def self.public_wiki_id
|
||||
idlist = "("
|
||||
wikis=Wiki.where("project_id in " + public_project_id)
|
||||
count = wikis.count
|
||||
for i in 0...count
|
||||
wiki = wikis[i]
|
||||
idlist+="'" + wiki.id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist = idlist + ","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
idlist
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 公开的board id列表
|
||||
def self.public_board_id
|
||||
idlist = "("
|
||||
boards=Board.where("project_id in " + public_project_id + " or course_id in " + public_course_id)
|
||||
count = boards.count
|
||||
for i in 0...count
|
||||
board = boards[i]
|
||||
idlist+="'" + board.id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist = idlist + ","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
idlist
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 公开的bid id列表
|
||||
def self.public_bid_id
|
||||
idlist = "("
|
||||
bids=Bid.where("reward_type=3")
|
||||
count = bids.count
|
||||
for i in 0...count
|
||||
bid = bids[i]
|
||||
idlist+="'" + bid.id.to_s + "'"
|
||||
if i != count-1
|
||||
idlist = idlist + ","
|
||||
end
|
||||
end
|
||||
idlist += ")"
|
||||
idlist
|
||||
end
|
||||
|
||||
# Returns an unsaved copy of the attachment
|
||||
def copy(attributes=nil)
|
||||
copy = self.class.new
|
||||
|
|
@ -229,7 +129,7 @@ class Attachment < ActiveRecord::Base
|
|||
nil
|
||||
end
|
||||
|
||||
def filename=(arg)
|
||||
def filename=(arg)
|
||||
write_attribute :filename, sanitize_filename(arg.to_s)
|
||||
filename
|
||||
end
|
||||
|
|
@ -279,7 +179,6 @@ class Attachment < ActiveRecord::Base
|
|||
File.join(self.class.storage_path, disk_directory.to_s, disk_filename.to_s)
|
||||
end
|
||||
|
||||
#标题
|
||||
def title
|
||||
title = filename.to_s
|
||||
if description.present?
|
||||
|
|
@ -484,7 +383,7 @@ class Attachment < ActiveRecord::Base
|
|||
type = self.container_type
|
||||
types = %w|Document News Version Project Issue Message WikiPage|
|
||||
if types.include?(type)
|
||||
UserScore.project(:push_file, User.current,self, { attachment_id: self.id })
|
||||
UserScore.project(:push_file, User.current, { attachment_id: self.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Changeset < ActiveRecord::Base
|
|||
belongs_to :repository
|
||||
belongs_to :user
|
||||
|
||||
#after_save :be_user_score # user_score
|
||||
after_save :be_user_score # user_score
|
||||
|
||||
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
|
||||
# fq
|
||||
|
|
@ -63,7 +63,7 @@ class Changeset < ActiveRecord::Base
|
|||
includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args))
|
||||
}
|
||||
|
||||
after_create :scan_for_issues,:be_user_score # user_score
|
||||
after_create :scan_for_issues
|
||||
before_create :before_create_cs
|
||||
|
||||
# fq
|
||||
|
|
@ -98,9 +98,7 @@ class Changeset < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def project
|
||||
unless repository.nil?
|
||||
repository.project
|
||||
end
|
||||
repository.project
|
||||
end
|
||||
|
||||
def author
|
||||
|
|
@ -302,9 +300,11 @@ class Changeset < ActiveRecord::Base
|
|||
|
||||
# update user score
|
||||
def be_user_score
|
||||
UserScore.project(:push_code, self.user,self, { changeset_id: self.id })
|
||||
if self.new_record?
|
||||
UserScore.project(:push_code, self.user, { changeset_id: self.id })
|
||||
#更新用户等级
|
||||
UserLevels.update_user_level(self.user)
|
||||
self.user.update_user_level
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@ class Contest < ActiveRecord::Base
|
|||
|
||||
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
|
||||
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
|
||||
validates_presence_of :author_id, :name, :budget
|
||||
#validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
|
||||
validates_format_of :deadline, :with =>/^[1-9][0-9]{3}\-0?[1-9]|1[12]\-0?[1-9]|[12]\d|3[01]$/
|
||||
validates_presence_of :author_id, :name, :deadline
|
||||
validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
|
||||
# validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
|
||||
validate :validate_user
|
||||
after_create :act_as_activity
|
||||
|
|
|
|||
|
|
@ -27,18 +27,15 @@ class Course < ActiveRecord::Base
|
|||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||
#has_many :course_journals_for_messages, :class_name => 'CourseJournalsForMessage', :as => :jour, :dependent => :destroy
|
||||
has_many :news, :dependent => :destroy, :include => :author
|
||||
has_one :course_status, :class_name => "CourseStatus", :dependent => :destroy
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
acts_as_attachable :view_permission => :view_files,
|
||||
:delete_permission => :manage_files
|
||||
|
||||
validates_presence_of :password, :term,:name
|
||||
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
||||
validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/
|
||||
validates_presence_of :password, :term
|
||||
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
|
||||
|
||||
before_save :self_validate
|
||||
after_save :create_board_sync
|
||||
before_destroy :delete_all_members
|
||||
|
||||
|
|
@ -78,7 +75,7 @@ class Course < ActiveRecord::Base
|
|||
where(nil)
|
||||
else
|
||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||
where(" LOWER(name) LIKE :p ", :p => pattern)
|
||||
where("LOWER(extra) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
||||
end
|
||||
}
|
||||
|
||||
|
|
@ -167,8 +164,10 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
|
||||
#自定义验证
|
||||
def self_validate
|
||||
|
||||
def validate
|
||||
if !class_period.match([0-9])
|
||||
errors.add_to_base("class period can only digital")
|
||||
end
|
||||
end
|
||||
|
||||
# 创建课程讨论区
|
||||
|
|
@ -200,11 +199,9 @@ class Course < ActiveRecord::Base
|
|||
|
||||
# 删除课程所有成员
|
||||
def delete_all_members
|
||||
if self.members && self.members.count > 0
|
||||
me, mr = Member.table_name, MemberRole.table_name
|
||||
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
|
||||
Member.delete_all(['course_id = ?', id])
|
||||
end
|
||||
me, mr = Member.table_name, MemberRole.table_name
|
||||
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
|
||||
Member.delete_all(['course_id = ?', id])
|
||||
end
|
||||
|
||||
def get_endup_time
|
||||
|
|
@ -274,8 +271,4 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
|
||||
def name
|
||||
read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
class CourseStatus < ActiveRecord::Base
|
||||
attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count
|
||||
|
||||
belongs_to :course
|
||||
validates_presence_of :course_id
|
||||
validates_uniqueness_of :course_id
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Document < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||
|
||||
after_create :be_user_score # user_score
|
||||
before_save :be_user_score # user_score
|
||||
|
||||
|
||||
acts_as_attachable :delete_permission => :delete_documents
|
||||
|
|
@ -62,6 +62,8 @@ class Document < ActiveRecord::Base
|
|||
|
||||
# update user score
|
||||
def be_user_score
|
||||
UserScore.project(:push_document, self.user,self,{ document_id: self.id })
|
||||
if self.new_record?
|
||||
UserScore.project(:push_document, self.user, { document_id: self.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Forum < ActiveRecord::Base
|
|||
'memo_count',
|
||||
'last_memo_id',
|
||||
'creator_id'
|
||||
validates_presence_of :name, :creator_id, :description
|
||||
validates_presence_of :name, :creator_id
|
||||
validates_length_of :name, maximum: 50
|
||||
validates_length_of :description, maximum: 255
|
||||
validates :name, :uniqueness => true
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class HomeworkAttach < ActiveRecord::Base
|
|||
has_many :homework_users, :dependent => :destroy
|
||||
has_many :users, :through => :homework_users
|
||||
seems_rateable :allow_update => true, :dimensions => :quality
|
||||
belongs_to :project
|
||||
|
||||
safe_attributes "bid_id",
|
||||
"user_id"
|
||||
|
|
@ -31,7 +30,7 @@ class HomeworkAttach < ActiveRecord::Base
|
|||
result
|
||||
end
|
||||
|
||||
def project_for_homework
|
||||
def project
|
||||
work = HomeworkForCourse.find_by_bid_id(self.bid_id)
|
||||
if work
|
||||
work.project
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ class Issue < ActiveRecord::Base
|
|||
attr_reader :current_journal
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score_new_issue
|
||||
after_update :be_user_score
|
||||
after_create :act_as_activity
|
||||
before_save :be_user_score
|
||||
# after_create :be_user_score
|
||||
# end
|
||||
|
||||
|
|
@ -990,9 +990,13 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def to_s
|
||||
"#{tracker} ##{project_index}: #{subject}"
|
||||
"#{tracker} ##{id}: #{subject}"
|
||||
end
|
||||
|
||||
# 缺陷在项目中的序号
|
||||
def inProjectIndex
|
||||
(self.project.issues.index(self).to_i + 1).to_s
|
||||
end
|
||||
|
||||
# Returns a string of css classes that apply to the issue
|
||||
def css_classes
|
||||
|
|
@ -1156,22 +1160,9 @@ class Issue < ActiveRecord::Base
|
|||
"" << self.project.name.to_s <<
|
||||
"#" << project_index
|
||||
end
|
||||
|
||||
|
||||
def project_index
|
||||
if self.project.issues.include?(self)
|
||||
(self.project.issues.index(self).to_i + 1).to_s
|
||||
else
|
||||
issue_index = 1
|
||||
self.project.issues.each do |issue|
|
||||
if self.id == nil
|
||||
issue_index = self.project.issues.count +1
|
||||
break
|
||||
elsif self.id > issue.id
|
||||
issue_index = issue_index+1
|
||||
end
|
||||
end
|
||||
issue_index.to_s
|
||||
end
|
||||
(self.project.issues.index(self).to_i + 1).to_s
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -1498,19 +1489,14 @@ class Issue < ActiveRecord::Base
|
|||
|
||||
# update user score
|
||||
def be_user_score
|
||||
#缺陷完成度更新
|
||||
if self.done_ratio_changed?
|
||||
UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id })
|
||||
end
|
||||
if self.new_record?
|
||||
UserScore.project(:post_issue, User.current, { issue_id: self.id })
|
||||
elsif self.done_ratio_changed?
|
||||
UserScore.project(:update_issue_ratio, User.current, { issue_id: self.id })
|
||||
#缺陷状态更改
|
||||
if self.status_id_changed?
|
||||
#协同得分
|
||||
UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id})
|
||||
elsif self.status_id_changed?
|
||||
#协同得分
|
||||
UserScore.joint(:change_issue_status, User.current,nil, {issue_id: self.id})
|
||||
end
|
||||
end
|
||||
|
||||
#发布缺陷
|
||||
def be_user_score_new_issue
|
||||
UserScore.project(:post_issue, User.current,self, { issue_id: self.id })
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class Journal < ActiveRecord::Base
|
|||
# end
|
||||
attr_accessor :indice
|
||||
|
||||
acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" },
|
||||
acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.inProjectIndex}#{status}: #{o.issue.subject}" },
|
||||
:description =>:notes,
|
||||
:author => :user,
|
||||
:group => :issue,
|
||||
|
|
@ -45,10 +45,10 @@ class Journal < ActiveRecord::Base
|
|||
before_create :split_private_notes
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score
|
||||
after_create :act_as_activity
|
||||
# end
|
||||
|
||||
#before_save :be_user_score
|
||||
before_save :be_user_score
|
||||
#before_destroy :down_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
|
@ -158,9 +158,9 @@ class Journal < ActiveRecord::Base
|
|||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了缺陷留言且留言不为空,不为空白
|
||||
if !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||
if self.new_record? && !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||
#协同得分加分
|
||||
UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id })
|
||||
UserScore.joint(:post_issue, User.current,self.issue.author, { message_id: self.id })
|
||||
end
|
||||
end
|
||||
# 减少用户分数 -by zjc
|
||||
|
|
@ -168,7 +168,7 @@ class Journal < ActiveRecord::Base
|
|||
#删除有效缺陷留言
|
||||
if !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||
#协同得分减分
|
||||
UserScore.joint(:delete_issue_message, User.current,self.issue.author, { message_id: self.id })
|
||||
UserScore.joint(:delete_issue, User.current,self.issue.author, { message_id: self.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
"m_reply_id" # 回复某留言的留言id(a留言回复了b留言,这是b留言的id)
|
||||
acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC"
|
||||
|
||||
belongs_to :project,
|
||||
:foreign_key => 'jour_id',
|
||||
belongs_to :project,
|
||||
:foreign_key => 'jour_id',
|
||||
:conditions => "#{self.table_name}.jour_type = 'Project' "
|
||||
belongs_to :course,
|
||||
:foreign_key => 'jour_id',
|
||||
|
|
@ -33,13 +33,9 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
:description => Proc.new{|o| o.notes },
|
||||
:type => Proc.new {|o| o.jour_type },
|
||||
:url => Proc.new {|o|
|
||||
if o.jour.kind_of? Project
|
||||
{:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"}
|
||||
elsif o.jour.kind_of? Course
|
||||
{:controller => 'courses', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"}
|
||||
end
|
||||
}
|
||||
acts_as_activity_provider :author_key => :user_id,
|
||||
(o.jour.kind_of? Project) ? {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} : {}
|
||||
}#{:controller => 'documents', :action => 'show', :id => o.id}}
|
||||
acts_as_activity_provider :author_key => :user_id,
|
||||
:timestamp => "#{self.table_name}.updated_on",
|
||||
:find_options => {:include => :project }
|
||||
|
||||
|
|
@ -53,9 +49,9 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
validates :notes, presence: true
|
||||
after_create :act_as_activity #huang
|
||||
after_create :reset_counters!,:be_user_score
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
#before_save :be_user_score
|
||||
before_save :be_user_score
|
||||
#before_destroy :down_user_score
|
||||
|
||||
# default_scope { where('m_parent_id IS NULL') }
|
||||
|
|
@ -117,21 +113,12 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
update_all("m_reply_count = #{count.to_i}", ["id = ?", journals_for_messages.m_parent_id])
|
||||
end
|
||||
|
||||
#如果是在项目中留言则返回该项目否则返回nil - zjc
|
||||
def project
|
||||
if self.jour_type == 'Project'
|
||||
Project.find(self.jour_id)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建了留言回复
|
||||
if self.reply_id != 0
|
||||
if self.new_record? && self.reply_id != 0
|
||||
#协同得分加分
|
||||
UserScore.joint(:reply_message, User.current,User.find(self.reply_id),self, { journals_for_messages_id: self.id })
|
||||
UserScore.joint(:reply_message, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
|
||||
end
|
||||
end
|
||||
# 更新用户分数 -by zjc
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ class Mailer < ActionMailer::Base
|
|||
when :Project
|
||||
return -1 if journals_for_message.jour.project_type == Project::ProjectType_project
|
||||
project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
|
||||
when :Course
|
||||
course_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
|
||||
when :Contest
|
||||
show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
|
||||
when :User
|
||||
|
|
@ -56,10 +54,9 @@ class Mailer < ActionMailer::Base
|
|||
Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
|
||||
return -1
|
||||
end
|
||||
# modify by nwb
|
||||
#如果是直接留言并且留言对象是课程
|
||||
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
|
||||
course = journals_for_message.jour
|
||||
#如果是直接留言并且留言对象是Project并且Project类型是课程
|
||||
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Project && journals_for_message.jour.project_type == 1
|
||||
project = journals_for_message.jour
|
||||
@author = journals_for_message.user
|
||||
#课程的教师
|
||||
@teachers = searchTeacherAndAssistant journals_for_message.jour
|
||||
|
|
@ -78,12 +75,7 @@ class Mailer < ActionMailer::Base
|
|||
return -1
|
||||
end
|
||||
mail :to => journals_for_message.jour.author.mail, :subject => @title
|
||||
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
|
||||
if !journals_for_message.jour.author.notify_about? journals_for_message
|
||||
return -1
|
||||
end
|
||||
mail :to => journals_for_message.jour.author.mail, :subject => @title
|
||||
else
|
||||
else
|
||||
mail :to => @mail.mail, :subject => @title
|
||||
end
|
||||
|
||||
|
|
@ -96,9 +88,8 @@ class Mailer < ActionMailer::Base
|
|||
# issue_add(issue) => Mail::Message object
|
||||
# Mailer.issue_add(issue).deliver => sends an email to issue recipients
|
||||
def issue_add(issue)
|
||||
issue_id = issue.project_index
|
||||
redmine_headers 'Project' => issue.project.identifier,
|
||||
'Issue-Id' => issue_id,
|
||||
'Issue-Id' => (issue.project.issues.index(issue).to_i + 1).to_s,
|
||||
'Issue-Author' => issue.author.login
|
||||
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||
message_id issue
|
||||
|
|
@ -109,7 +100,7 @@ class Mailer < ActionMailer::Base
|
|||
cc = issue.watcher_recipients - recipients
|
||||
mail :to => recipients,
|
||||
:cc => cc,
|
||||
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
|
||||
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
|
||||
end
|
||||
|
||||
# Builds a Mail::Message object used to email recipients of the edited issue.
|
||||
|
|
@ -119,9 +110,8 @@ class Mailer < ActionMailer::Base
|
|||
# Mailer.issue_edit(journal).deliver => sends an email to issue recipients
|
||||
def issue_edit(journal)
|
||||
issue = journal.journalized.reload
|
||||
issue_id = issue.project_index
|
||||
redmine_headers 'Project' => issue.project.identifier,
|
||||
'Issue-Id' => issue_id.to_s,
|
||||
'Issue-Id' => (issue.project.issues.index(issue).to_i + 1).to_s,
|
||||
'Issue-Author' => issue.author.login
|
||||
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||
message_id journal
|
||||
|
|
@ -130,7 +120,7 @@ class Mailer < ActionMailer::Base
|
|||
recipients = journal.recipients
|
||||
# Watchers in cc
|
||||
cc = journal.watcher_recipients - recipients
|
||||
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
|
||||
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
|
||||
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
|
||||
s << issue.subject
|
||||
@issue = issue
|
||||
|
|
|
|||
|
|
@ -3,16 +3,15 @@ class Memo < ActiveRecord::Base
|
|||
belongs_to :forum
|
||||
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
||||
|
||||
validates_presence_of :author_id, :forum_id, :subject,:content
|
||||
validates_presence_of :author_id, :forum_id, :subject
|
||||
# 若是主题帖,则内容可以是空
|
||||
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
||||
validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
||||
validates_length_of :subject, maximum: 50
|
||||
validates_length_of :content, maximum: 3072
|
||||
validate :cannot_reply_to_locked_topic, :on => :create
|
||||
|
||||
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC"
|
||||
acts_as_attachable
|
||||
has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj
|
||||
belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id'
|
||||
# acts_as_searchable :column => ['subject', 'content'],
|
||||
# #:include => { :forum => :p}
|
||||
|
|
@ -41,13 +40,13 @@ class Memo < ActiveRecord::Base
|
|||
"parent_id",
|
||||
"replies_count"
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!,:be_user_score
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
# after_update :update_memos_forum
|
||||
after_destroy :reset_counters!
|
||||
# after_create :send_notification
|
||||
# after_save :plusParentAndForum
|
||||
# after_destroy :minusParentAndForum
|
||||
#before_save :be_user_score
|
||||
before_save :be_user_score
|
||||
# scope :visible, lambda { |*args|
|
||||
# includes(:forum => ).where()
|
||||
# }
|
||||
|
|
@ -146,11 +145,11 @@ class Memo < ActiveRecord::Base
|
|||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建memo且无parent的为发帖
|
||||
if self.parent_id.nil?
|
||||
UserScore.joint(:post_message, User.current,nil,self ,{ memo_id: self.id })
|
||||
if self.new_record? && self.parent_id.nil?
|
||||
UserScore.joint(:post_message, User.current,nil, { memo_id: self.id })
|
||||
#新建memo且有parent的为回帖
|
||||
elsif !self.parent_id.nil?
|
||||
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { memo_id: self.id })
|
||||
elsif self.new_record? && !self.parent_id.nil?
|
||||
UserScore.joint(:reply_posting, User.current,self.parent.author, { memo_id: self.id })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ class Message < ActiveRecord::Base
|
|||
after_destroy :reset_counters!
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score
|
||||
#before_save :be_user_score
|
||||
after_create :act_as_activity
|
||||
before_save :be_user_score
|
||||
#before_destroy :down_user_score
|
||||
# end
|
||||
|
||||
|
|
@ -147,11 +147,11 @@ class Message < ActiveRecord::Base
|
|||
#更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#新建message且无parent的为发帖
|
||||
if self.parent_id.nil?
|
||||
UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id })
|
||||
if self.new_record? && self.parent_id.nil?
|
||||
UserScore.joint(:post_message, User.current,nil, { message_id: self.id })
|
||||
#新建message且有parent的为回帖
|
||||
elsif !self.parent_id.nil?
|
||||
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id })
|
||||
elsif self.new_record? && !self.parent_id.nil?
|
||||
UserScore.joint(:reply_posting, User.current,self.parent.author, { message_id: self.id })
|
||||
end
|
||||
end
|
||||
#减少用户分数
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ class PraiseTread < ActiveRecord::Base
|
|||
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
|
||||
belongs_to :user
|
||||
belongs_to :praise_tread_object, polymorphic: true
|
||||
after_create :be_user_score
|
||||
before_save :be_user_score
|
||||
|
||||
def self.find_object_by_type_and_id(type,id)
|
||||
@obj = nil
|
||||
|
|
@ -25,30 +25,20 @@ class PraiseTread < ActiveRecord::Base
|
|||
return @obj
|
||||
end
|
||||
|
||||
# 获取裁定对象为Message时Message所属的项目或课程
|
||||
def project
|
||||
project = nil
|
||||
if self.praise_tread_object_type == 'Message'
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
project = obj.project
|
||||
end
|
||||
project
|
||||
end
|
||||
|
||||
#更新用户分数 - by zjc
|
||||
def be_user_score
|
||||
#踩贴吧或讨论区帖子
|
||||
if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||
if self.new_record? && self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
target_user = obj.author
|
||||
UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
|
||||
UserScore.skill(:treaded_by_user, User.current,target_user, { praise_tread_id: self.id })
|
||||
#顶贴吧或讨论区帖子
|
||||
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||
elsif self.new_record? && self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||
target_user = obj.author
|
||||
UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
|
||||
UserScore.skill(:praised_by_user, User.current,target_user,{ praise_tread_id: self.id })
|
||||
#更新用户等级
|
||||
UserLevels.update_user_level(target_user)
|
||||
target_user.update_user_level
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Project < ActiveRecord::Base
|
|||
|
||||
# Specific overidden Activities
|
||||
|
||||
belongs_to :homework_attach
|
||||
has_many :time_entry_activities
|
||||
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
|
||||
has_many :memberships, :class_name => 'Member'
|
||||
|
|
@ -41,7 +40,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :principals, :through => :member_principals, :source => :principal
|
||||
has_many :enabled_modules, :dependent => :delete_all
|
||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker] , :order => "id ASC"
|
||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
||||
has_many :issue_changes, :through => :issues, :source => :journals
|
||||
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
|
||||
has_many :time_entries, :dependent => :delete_all
|
||||
|
|
@ -113,7 +112,6 @@ class Project < ActiveRecord::Base
|
|||
|
||||
validates_presence_of :name, :identifier
|
||||
validates_uniqueness_of :identifier
|
||||
validates_uniqueness_of :name
|
||||
validates_associated :repository, :wiki
|
||||
# validates_length_of :description, :maximum => 255
|
||||
validates_length_of :name, :maximum => 255
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ class ProjectInfo < ActiveRecord::Base
|
|||
|
||||
#更新用户等级
|
||||
def update_user_level
|
||||
UserLevels.update_user_level(self.user)
|
||||
self.user.update_user_level
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ class Repository < ActiveRecord::Base
|
|||
|
||||
validates_length_of :password, :maximum => 255, :allow_nil => true
|
||||
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
|
||||
validates_presence_of :identifier#, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
||||
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
||||
validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
|
||||
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||
# donwcase letters, digits, dashes, underscores but not digits only
|
||||
validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]+$/, :allow_blank => true
|
||||
validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true
|
||||
# Checks if the SCM is enabled when creating a repository
|
||||
validate :repo_create_validation, :on => :create
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class User < Principal
|
|||
# Prevents unauthorized assignments
|
||||
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
||||
|
||||
LOGIN_LENGTH_LIMIT = 25
|
||||
LOGIN_LENGTH_LIMIT = 60
|
||||
MAIL_LENGTH_LIMIT = 60
|
||||
|
||||
validates_presence_of :login, :firstname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
||||
|
|
@ -202,8 +202,7 @@ class User < Principal
|
|||
where(nil)
|
||||
else
|
||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||
#where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
|
||||
where(" LOWER(login) LIKE :p ", :p => pattern)
|
||||
where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
|
||||
end
|
||||
}
|
||||
|
||||
|
|
@ -577,16 +576,15 @@ class User < Principal
|
|||
# Find a user account by matching the exact login and then a case-insensitive
|
||||
# version. Exact matches will be given priority.
|
||||
#通过用户名查找相应的用户,若没有匹配到,则不区分大小写进行查询
|
||||
#修改:不再匹配不区分大小写情况 -zjc
|
||||
def self.find_by_login(login)
|
||||
if login.present?
|
||||
login = login.to_s
|
||||
# First look for an exact match
|
||||
user = where(:login => login).all.detect {|u| u.login == login}
|
||||
#unless user
|
||||
# # Fail over to case-insensitive if none was found
|
||||
# user = where("LOWER(login) = ?", login.downcase).first
|
||||
#end
|
||||
unless user
|
||||
# Fail over to case-insensitive if none was found
|
||||
user = where("LOWER(login) = ?", login.downcase).first
|
||||
end
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
@ -957,6 +955,63 @@ class User < Principal
|
|||
end
|
||||
end
|
||||
|
||||
#获取user的等级 -by zjc
|
||||
def get_level
|
||||
if self.level.nil?
|
||||
update_user_level
|
||||
end
|
||||
self.level.level
|
||||
end
|
||||
|
||||
#更新用户等级 - by zjc
|
||||
def update_user_level
|
||||
user_level = self.level.nil? ? UserLevels.new : self.level
|
||||
user_level.user = self
|
||||
|
||||
#判断user的等级
|
||||
pis = self.project_infos #ProjectInfo.find_all_by_user_id(self.id)
|
||||
isManager = false;
|
||||
pis.each do |pi|
|
||||
#判断是否为项目管理员
|
||||
if self.allowed_to?({:controller => "projects", :action => "edit"}, pi.project)
|
||||
isManager = true;
|
||||
end
|
||||
end
|
||||
has_effective_praise_count = false;
|
||||
self.messages.each do |message|
|
||||
if message.parent_id.nil?
|
||||
ptcs = PraiseTreadCache.find_all_by_object_id(message.id)
|
||||
ptcs.each do |ptc|
|
||||
if ptc.object_type == 'Message' && ptc.praise_num.to_i > 5
|
||||
has_effective_praise_count = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if !has_effective_praise_count
|
||||
self.memos do |memo|
|
||||
if memo.parent_id.nil?
|
||||
ptcs = PraiseTreadCache.find_all_by_object_id(memo.id)
|
||||
ptcs.each do |ptc|
|
||||
if ptc.object_type == 'Memo' && ptc.praise_num > 5
|
||||
has_effective_praise_count = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if isManager || self.changesets.count > 100
|
||||
user_level.level = 3
|
||||
elsif (self.changesets.count > 1 && self.changesets.count <= 100) || has_effective_praise_count
|
||||
user_level.level = 2
|
||||
else
|
||||
user_level.level = 1
|
||||
end
|
||||
user_level.save
|
||||
self.reload
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def validate_password_length
|
||||
|
|
|
|||
|
|
@ -2,37 +2,4 @@ class UserGrade < ActiveRecord::Base
|
|||
# attr_accessible :title, :body
|
||||
attr_accessible :user_id, :project_id, :grade
|
||||
belongs_to :project
|
||||
before_save :correct_score
|
||||
validates_uniqueness_of :user_id, :scope => [:project_id]
|
||||
#validate :my_validation
|
||||
|
||||
#修正分数
|
||||
#分数小于0时修正为0
|
||||
#分数大于等于0时不修正 -by zjc
|
||||
def correct_score
|
||||
if !self.grade.nil? && self.grade < 0
|
||||
self.grade = 0
|
||||
end
|
||||
end
|
||||
|
||||
#def self.exit_user_and_project(user,project)
|
||||
# unless user.nil? || project.nil?
|
||||
# if user.class.to_s == 'User' && project.class.to_s == 'Project'
|
||||
# user_grade = UserGrade.find_by_user_id_and_project_id(user.id,project.id)
|
||||
# user_grade
|
||||
# else
|
||||
# nil
|
||||
# end
|
||||
# else
|
||||
# nil
|
||||
# end
|
||||
#end
|
||||
|
||||
#def my_validation
|
||||
# if user_id.nil? || project_id.nil?
|
||||
# errors[:Base] << "用户和项目不能为空"
|
||||
# elsif UserGrade.exit_user_and_project(user_id,project_id)
|
||||
# errors[:Base] << "当前记录已存在"
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,67 +2,4 @@
|
|||
class UserLevels < ActiveRecord::Base
|
||||
attr_accessible :user_id, :level
|
||||
belongs_to :user
|
||||
|
||||
#获取user的等级 -by zjc
|
||||
def self.get_level(user)
|
||||
unless user.nil?
|
||||
if user.level.nil?
|
||||
UserLevels.update_user_level(user)
|
||||
end
|
||||
user.level.level
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#更新用户的等级 -by zjc
|
||||
def self.update_user_level(user)
|
||||
unless user.nil?
|
||||
user_level = user.level.nil? ? UserLevels.new : user.level
|
||||
user_level.user = user
|
||||
|
||||
#判断user的等级
|
||||
pis = user.project_infos #ProjectInfo.find_all_by_user_id(self.id)
|
||||
isManager = false;
|
||||
pis.each do |pi|
|
||||
#判断是否为项目管理员
|
||||
if user.allowed_to?({:controller => "projects", :action => "edit"}, pi.project)
|
||||
isManager = true;
|
||||
end
|
||||
end
|
||||
has_effective_praise_count = false;
|
||||
user.messages.each do |message|
|
||||
if message.parent_id.nil?
|
||||
ptcs = PraiseTreadCache.find_all_by_object_id(message.id)
|
||||
ptcs.each do |ptc|
|
||||
if ptc.object_type == 'Message' && ptc.praise_num.to_i > 5
|
||||
has_effective_praise_count = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if !has_effective_praise_count
|
||||
user.memos do |memo|
|
||||
if memo.parent_id.nil?
|
||||
ptcs = PraiseTreadCache.find_all_by_object_id(memo.id)
|
||||
ptcs.each do |ptc|
|
||||
if ptc.object_type == 'Memo' && ptc.praise_num > 5
|
||||
has_effective_praise_count = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if isManager || user.changesets.count > 100
|
||||
user_level.level = 3
|
||||
elsif (user.changesets.count > 1 && user.changesets.count <= 100) || has_effective_praise_count
|
||||
user_level.level = 2
|
||||
else
|
||||
user_level.level = 1
|
||||
end
|
||||
user_level.save
|
||||
user.reload
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -48,79 +48,46 @@ class UserScore < ActiveRecord::Base
|
|||
# # => true #当前用户发帖计分操作成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.joint(operate, current_user, target_user,obj, options={})
|
||||
def self.joint(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = current_user.user_score_attr
|
||||
user_grade = nil #项目个人得分
|
||||
project = obj.project
|
||||
unless project.nil?
|
||||
user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
||||
if user_grade.nil?
|
||||
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
||||
end
|
||||
end
|
||||
case operate
|
||||
when :post_message # current_user 发帖了 Add Message
|
||||
user_score.collaboration = user_score.collaboration.to_i + 2
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade.to_i + 2
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration - 2,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
|
||||
#when :delete_message # current_user 删帖了 Delete Message
|
||||
# user_score.collaboration = user_score.collaboration.to_i - 2
|
||||
# user_score.save
|
||||
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
|
||||
when :post_issue_message # current_user 对 target_user 的缺陷留言了 Add Journal
|
||||
when :delete_message # current_user 发帖了 Delete Message
|
||||
user_score.collaboration = user_score.collaboration.to_i - 2
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
|
||||
when :post_issue # current_user 对 target_user 的缺陷留言了 Add Journal
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade.to_i + 1
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "post_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
|
||||
#when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
|
||||
# user_score.collaboration = user_score.collaboration.to_i - 1
|
||||
# user_score.save
|
||||
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
|
||||
when :delete_issue # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
|
||||
user_score.collaboration = user_score.collaboration.to_i - 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
|
||||
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade.to_i + 1
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "change_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
|
||||
when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade.to_i + 1
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
|
||||
#when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
|
||||
# user_score.collaboration = user_score.collaboration.to_i - 1
|
||||
# user_score.save
|
||||
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
|
||||
when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
|
||||
user_score.collaboration = user_score.collaboration.to_i - 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
|
||||
when :reply_posting # current_user 对 target_user 帖子的回复 Add Message
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade.to_i + 1
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_posting",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
|
||||
#when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
|
||||
# user_score.collaboration = user_score.collaboration.to_i - 1
|
||||
# user_score.save
|
||||
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
|
||||
when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
|
||||
user_score.collaboration = user_score.collaboration.to_i - 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
|
||||
return false
|
||||
|
|
@ -139,19 +106,17 @@ class UserScore < ActiveRecord::Base
|
|||
# # => true #当前被关注用户记分成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.influence(operate, current_user, target_user,obj, options={})
|
||||
def self.influence(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = target_user.user_score_attr
|
||||
case operate
|
||||
when :followed_by # current_user 关注了target_user Add watcher
|
||||
user_score.influence = user_score.influence.to_i + 2
|
||||
user_score.save
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "influence",:score_action => "followed_by",:user_id => target_user.id,:old_score => user_score.influence - 2,:new_score => user_score.influence,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
|
||||
when :cancel_followed # current_uer 取消了对 target_user的关注 delete watcher
|
||||
user_score.influence = user_score.influence.to_i - 2
|
||||
user_score.save
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "influence",:score_action => "cancel_followed",:user_id => target_user.id,:old_score => user_score.influence + 2,:new_score => user_score.influence,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} canceled followed. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
|
||||
|
|
@ -171,96 +136,46 @@ class UserScore < ActiveRecord::Base
|
|||
# # => true #当前current_user对target_user用户帖子的记分成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.skill(operate, current_user, target_user,obj, options={})
|
||||
def self.skill(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
current_user_score = current_user.user_score_attr
|
||||
target_user_score = target_user.user_score_attr
|
||||
current_user_grade = nil #项目个人得分
|
||||
target_user_grade = nil
|
||||
project = obj.project
|
||||
unless project.nil?
|
||||
current_user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
||||
target_user_grade = UserGrade.find_by_user_id_and_project_id(target_user.id, project.id)
|
||||
if current_user_grade.nil?
|
||||
current_user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
||||
end
|
||||
if target_user_grade.nil?
|
||||
target_user_grade = UserGrade.create(:user_id => target_user.id,:project_id => project.id)
|
||||
end
|
||||
end
|
||||
case operate
|
||||
# when :treading # current_user 踩了 target_user 的帖子
|
||||
# Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treading #{target_user}'s posting. options => (#{options.to_s})"
|
||||
when :treaded_by_user # current_user 踩了 target_user 的帖子
|
||||
current_user_score.skill = current_user_score.skill.to_i - 2 #踩别人的帖子减2分 add praise_tread
|
||||
current_user_score.save
|
||||
unless current_user_grade.nil?
|
||||
current_user_grade.grade = current_user_grade.grade - 2
|
||||
current_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => current_user.id,:old_score => current_user_score.skill + 2,:new_score => current_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
if current_user.id == target_user.id
|
||||
target_user.reload
|
||||
target_user_score = target_user.user_score_attr
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.reload
|
||||
end
|
||||
end
|
||||
level = UserLevels.get_level(current_user)
|
||||
level = current_user.get_level
|
||||
if level == 1
|
||||
target_user_score.skill = target_user_score.skill.to_i - 2 #帖子被一级会员踩-2分 add praise_tread
|
||||
target_user_score.save
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.grade = target_user_grade.grade - 2
|
||||
target_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 2,:new_score => target_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
elsif level == 2
|
||||
target_user_score.skill = target_user_score.skill.to_i - 4 #帖子被二级会员踩-4分 add praise_tread
|
||||
target_user_score.save
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.grade = target_user_grade.grade - 4
|
||||
target_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 4,:new_score => target_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
elsif level == 3
|
||||
target_user_score.skill = target_user_score.skill.to_i - 6 #帖子被三级会员踩-6分 add praise_tread
|
||||
target_user_score.save
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.grade = target_user_grade.grade - 6
|
||||
target_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 6,:new_score => target_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
end
|
||||
|
||||
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})"
|
||||
when :praised_by_user # current_user 顶了 target_user 的帖子
|
||||
level = UserLevels.get_level(current_user)
|
||||
level = current_user.get_level
|
||||
if level == 1
|
||||
target_user_score.skill = target_user_score.skill.to_i + 4 #帖子被一级会员顶+4分 add praise_tread
|
||||
target_user_score.save
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.grade = target_user_grade.grade + 4
|
||||
target_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 4,:new_score => target_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
elsif level == 2
|
||||
target_user_score.skill = target_user_score.skill.to_i + 6 #帖子被二级会员顶+6分 add praise_tread
|
||||
target_user_score.save
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.grade = target_user_grade.grade + 6
|
||||
target_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 6,:new_score => target_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
elsif level == 3
|
||||
target_user_score.skill = target_user_score.skill.to_i + 8 #帖子被三级会员顶+8分 add praise_tread
|
||||
target_user_score.save
|
||||
unless target_user_grade.nil?
|
||||
target_user_grade.grade = target_user_grade.grade + 8
|
||||
target_user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 8,:new_score => target_user_score.skill,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
end
|
||||
|
||||
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} praised_by #{target_user}. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#skill] ===> #{operate} is not define."
|
||||
|
|
@ -280,63 +195,30 @@ class UserScore < ActiveRecord::Base
|
|||
# # => true #当前current_user对项目贡献积分成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.project(operate, current_user,obj, options={})
|
||||
def self.project(operate, current_user, options={})
|
||||
current_user, target_user = get_users(current_user, nil)
|
||||
user_score = current_user.try(:user_score_attr)
|
||||
user_grade = nil #项目个人得分
|
||||
project = obj.project
|
||||
unless project.nil?
|
||||
user_grade = UserGrade.find_by_user_id_and_project_id(current_user.id, project.id)
|
||||
if user_grade.nil?
|
||||
user_grade = UserGrade.create(:user_id => current_user.id,:project_id => project.id)
|
||||
end
|
||||
end
|
||||
return false if current_user.nil?
|
||||
case operate
|
||||
when :push_code # current_user 提交了代码 changeset
|
||||
user_score = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade + 4
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_code",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed code one time. options => (#{options.to_s})"
|
||||
when :push_document # current_user 提交了文档 document
|
||||
when :push_document # current_user
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade + 4
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_document",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a document. options => (#{options.to_s})"
|
||||
when :push_file # current_user 提交了附件 attachment
|
||||
when :push_file # current_user
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade + 4
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_file",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a file. options => (#{options.to_s})"
|
||||
when :update_issue_ratio # current_user 更新了缺陷完成度 issue
|
||||
when :update_issue_ratio # current_user
|
||||
user_score.active = user_score.active.to_i + 2
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade + 2
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "update_issue_ratio",:user_id => current_user.id,:old_score => user_score.active - 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})"
|
||||
when :post_issue # current_user 发布了缺陷 issue
|
||||
when :post_issue # current_user
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
unless user_grade.nil?
|
||||
user_grade.grade = user_grade.grade + 4
|
||||
user_grade.save
|
||||
end
|
||||
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "post_issue",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] posting issue. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#project] ===> #{operate} is not define."
|
||||
|
|
@ -346,44 +228,6 @@ class UserScore < ActiveRecord::Base
|
|||
Rails.logger.error "[UserScore#project] ===> Exception: #{e}."
|
||||
end
|
||||
|
||||
#获取用户的user_score
|
||||
def self.score(user)
|
||||
if user.user_score.nil?
|
||||
us = UserScore.new
|
||||
us.user_id = user.id
|
||||
us.save
|
||||
us
|
||||
else
|
||||
user.user_score
|
||||
end
|
||||
end
|
||||
|
||||
#计算总得分
|
||||
def total_score
|
||||
score = self.influence.to_i + self.skill.to_i + self.collaboration.to_i + self.active.to_i
|
||||
score
|
||||
end
|
||||
|
||||
#创建分数改变记录 -by zjc
|
||||
def self.create_score_changed_details(attributes)
|
||||
if attributes.is_a? Hash
|
||||
usd = UserScoreDetails.new
|
||||
usd.current_user_id =attributes[:current_user_id]
|
||||
usd.target_user_id = attributes[:target_user_id]
|
||||
usd.score_type = attributes[:score_type]
|
||||
usd.score_action = attributes[:score_action]
|
||||
usd.user_id = attributes[:user_id]
|
||||
usd.old_score = attributes[:old_score]
|
||||
usd.new_score = attributes[:new_score]
|
||||
usd.current_user_level = attributes[:current_user_level]
|
||||
usd.target_user_level = attributes[:target_user_level]
|
||||
#usd.score_changeable_obj = attributes[:score_changeable_obj]
|
||||
usd.score_changeable_obj_id = attributes[:score_changeable_obj_id]
|
||||
usd.score_changeable_obj_type = attributes[:score_changeable_obj_type]
|
||||
usd.save
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.get_users(current_user, target_user)
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
class UserScoreDetails < ActiveRecord::Base
|
||||
attr_accessible :current_user_id, :current_user_level, :new_score, :old_score, :score_action, :score_changeable_obj_id, :score_changeable_obj_type, :score_type, :target_user_id, :target_user_level, :user_id
|
||||
belongs_to :score_changeable_obj,:polymorphic => true
|
||||
end
|
||||
|
|
@ -22,7 +22,7 @@ class Watcher < ActiveRecord::Base
|
|||
has_one :project_status
|
||||
has_one :users_status
|
||||
#end
|
||||
after_create :be_user_score
|
||||
before_save :be_user_score
|
||||
before_destroy :down_user_score
|
||||
|
||||
validates_presence_of :user
|
||||
|
|
@ -76,9 +76,9 @@ class Watcher < ActiveRecord::Base
|
|||
# 更新用户分数 -by zjc
|
||||
def be_user_score
|
||||
#添加了关注
|
||||
if self.watchable_type == 'Principal'
|
||||
if self.new_record? && self.watchable_type == 'Principal'
|
||||
#影响力得分
|
||||
UserScore.influence(:followed_by, self.user,self.watchable,self, { watcher_id: self.id })
|
||||
UserScore.influence(:followed_by, self.user,self.watchable, { watcher_id: self.id })
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -86,7 +86,7 @@ class Watcher < ActiveRecord::Base
|
|||
def down_user_score
|
||||
#取消关注
|
||||
if self.watchable_type == 'Principal'
|
||||
UserScore.influence(:cancel_followed, self.user,self.watchable,self, { watcher_id: self.id })
|
||||
UserScore.influence(:cancel_followed, self.user,self.watchable, { watcher_id: self.id })
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% if options[:author] %>
|
||||
<!-- modified by zjc author添加超链接 -->
|
||||
<span class="author"><%= link_to h(attachment.author),user_path(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
|
||||
<span class="author"><%= h(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
<% if @save_flag %>
|
||||
window.location.reload();
|
||||
<% else %>
|
||||
// alert('添加文件失败:\n<%=@save_message[0]%>');
|
||||
$('#ajax-modal').html('<h3 class="title">添加文件失败</h3><%=@save_message.join(', ')%>');
|
||||
|
||||
var el = $('#ajax-modal').first();
|
||||
var title = el.find('h3.title').text();
|
||||
el.dialog({
|
||||
width: '200px',
|
||||
modal: true,
|
||||
resizable: false,
|
||||
dialogClass: 'modal',
|
||||
title: title
|
||||
});
|
||||
|
||||
<% end %>
|
||||
|
|
@ -1,7 +1,2 @@
|
|||
$('#relation_file_form').show();
|
||||
<% if @project%>
|
||||
$('#relation_file').html('<%=render_attachments_for_new_project(@project, nil)%>');
|
||||
<% elsif @course%>
|
||||
$('#relation_file').html('<%=render_attachments_for_new_course(@course, nil)%>');
|
||||
<% end%>
|
||||
|
||||
|
|
|
|||
|
|
@ -42,17 +42,17 @@
|
|||
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
|
||||
</div>
|
||||
</span>
|
||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||
<span><%= l(:button_upload_photo) %></span>
|
||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||
<span><%= l(:button_upload_photo) %></span>
|
||||
</a>
|
||||
<span class="add_avatar" style="margin-left: -55px;width: 70px">
|
||||
<span class="add_avatar" style="margin-left: -55px;width: 70px">
|
||||
<%= file_field_tag 'avatar[image]',
|
||||
:id => nil,
|
||||
:class => 'file_selector',
|
||||
:style => 'width:70px;',#added by young
|
||||
:size => "1",
|
||||
:multiple => false,
|
||||
:onchange => 'addInputAvatar(this);',
|
||||
:onchange => 'addInputAvatar(this);',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
:description_placeholder => nil ,# l(:label_optional_description)
|
||||
:source_type => source.class.to_s,
|
||||
:source_id => source.id.to_s
|
||||
} %>
|
||||
} %>
|
||||
</span>
|
||||
</div>
|
||||
<% content_for :header_tags do %>
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
<table style="width: 200px;table-layout: fixed" >
|
||||
<tr>
|
||||
<% count = 0 %>
|
||||
<% for attachment in attachments %>
|
||||
<% if attachments.count == 1 %>
|
||||
<td title="<%= attachment.filename%>" style="width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%= render :partial => 'attachment', :locals => {:attachment => attachment} %>
|
||||
</td>
|
||||
<% elsif attachments.count == 2 %>
|
||||
<td title="<%= attachment.filename%>" style="width: 100px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<%= render :partial => 'attachment', :locals => {:attachment => attachment} %>
|
||||
</td>
|
||||
<% else %>
|
||||
<td title="<%= attachment.filename%>" style="width: 66px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<% if count == 3 %>
|
||||
<% break %>
|
||||
<% end %>
|
||||
<%= render :partial => 'attachment', :locals => {:attachment => attachment} %>
|
||||
<% count = count +1 %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
|
||||
<% if attachment.is_text? %>
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
:controller => 'attachments', :action => 'show',
|
||||
:id => attachment, :filename => attachment.filename,:style => "width:50px"%>
|
||||
<% end %>
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<span style="float: right">
|
||||
<% if(User.current.logged? && (!Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %>
|
||||
<%# 提交作业按钮 %>
|
||||
<!--<%#= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@course) %>-->
|
||||
<!--<%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@course) %>-->
|
||||
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
|
||||
<% if cur_user_homework!= nil && cur_user_homework.count == 0 %>
|
||||
<%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %>
|
||||
|
|
@ -41,19 +41,19 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><span class="font_lighter">
|
||||
<% bidding_project = bid.biding_projects.all
|
||||
temp = []
|
||||
bidding_project.each do |pro|
|
||||
<% @bidding_project = bid.biding_projects.all
|
||||
@temp = []
|
||||
@bidding_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
temp << pro
|
||||
@temp << pro
|
||||
end
|
||||
temp
|
||||
@temp
|
||||
end
|
||||
%>
|
||||
<% if bid.homework_type == 1%>
|
||||
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %></strong>)
|
||||
<% else %>
|
||||
<%= l(:label_x_homework_project, :count => temp.count) %>(<strong><%= link_to temp.count, course_for_bid_path(bid.id) %></strong>)
|
||||
<%= l(:label_x_homework_project, :count => @temp.count) %>(<strong><%= link_to @temp.count, course_for_bid_path(bid.id) %></strong>)
|
||||
<% end %></span>
|
||||
<span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span>
|
||||
<span style="float: right">
|
||||
|
|
@ -70,11 +70,11 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: '微软雅黑'"><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %>
|
||||
<%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family:' 微软雅黑'"><%= bid.budget%></span></strong>
|
||||
<td colspan="2"> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %>
|
||||
<%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong>
|
||||
<% else %>
|
||||
|
||||
<% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%#= l(:label_price) %><%#= l(:label_RMB_sign) %><%#= bid.budget%></strong></td> --></td>
|
||||
<% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" ><span class="font_description">
|
||||
|
|
@ -83,18 +83,18 @@
|
|||
</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<span class="font_lighter">
|
||||
<%= l(:label_create_time) %> : <%=format_time bid.created_on %></span><span style="float: right"> <%= l(:field_deadline) %> : <%=bid.deadline %>
|
||||
</span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<td align="left"><span class="font_lighter"><span> <%= l(:label_create_time) %> : <%=format_time bid.created_on %></span><span style="float: right"> <%= l(:field_deadline) %> : <%=bid.deadline %></span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full bid_pages %>
|
||||
<ul>
|
||||
<%= pagination_links_full bid_pages %>
|
||||
<ul>
|
||||
</div>
|
||||
|
|
@ -13,34 +13,7 @@
|
|||
<td width="500">
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<% if bid.reward_type.nil? or bid.reward_type == 1%>
|
||||
<strong>
|
||||
<%= l(:label_bids_reward_method) %>
|
||||
<span style="color: #ed8924;font-family: 14px; font-family: '微软雅黑'">
|
||||
<%= l(:label_call_bonus) %>
|
||||
<%= l(:label_RMB_sign) %>
|
||||
<%= bid.budget%>
|
||||
</span>
|
||||
</strong>
|
||||
<% elsif bid.reward_type == 2%>
|
||||
<strong>
|
||||
<%= l(:label_bids_reward_method) %>
|
||||
<span style="color: #15bccf;font-family: 14px; font-family: '微软雅黑'"><%= bid.budget%></span>
|
||||
</strong>
|
||||
<% else %> <!-- <strong>
|
||||
<%#= l(:label_bids_reward_method) %>
|
||||
<span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑">
|
||||
<%#= l(:label_bids_credit) %>
|
||||
<%#= bid.budget%>
|
||||
<%#= l(:label_bids_credit_number) %>
|
||||
</span></strong> -->
|
||||
<% end %>
|
||||
<!-- <td style="color: rgb(255, 0, 0);">
|
||||
<strong>
|
||||
<%#= l(:label_price) %>
|
||||
<%#= l(:label_RMB_sign) %>
|
||||
<%#= bid.budget%></strong></td> --></td>
|
||||
<td> <% if bid.reward_type.nil? or bid.reward_type == 1%> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%></span></strong> <% elsif bid.reward_type == 2%> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong> <% else %> <!-- <strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %></span></strong> --> <% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td>
|
||||
</tr>
|
||||
<% if bid.reward_type == 3 %>
|
||||
<tr>
|
||||
|
|
@ -87,6 +60,6 @@
|
|||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full bid_pages %>
|
||||
</ul>
|
||||
<ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -21,48 +21,22 @@
|
|||
$.globalEval(submit_homework());
|
||||
return false;
|
||||
}
|
||||
|
||||
function show()
|
||||
{
|
||||
$("#what_is_project_div").slideToggle();
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<% if User.current.logged? && User.current.member_of_course?(@bid.courses.first) && cur_user_homework_for_bid(@bid).count == 0 && is_cur_course_student(@bid.courses.first) %>
|
||||
<% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? &&
|
||||
(Member.where('user_id = ? and project_id = ?', User.current.id,
|
||||
@bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) && cur_user_homework_for_bid(@bid).count == 0 %>
|
||||
<div class='icon icon-add'>
|
||||
<%#= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %>
|
||||
<%= link_to l(:label_course_new_homework),new_homework_attach_path %><strong style="color: #a9a9a9"> (每一个作业都可以是一个精美的作品)</strong>
|
||||
<!-- <%= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %> -->
|
||||
<%= link_to l(:label_course_new_homework),new_homework_attach_path %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 50%">
|
||||
<% if @homework_list.empty? %>
|
||||
<div class="font_lighter_sidebar" style="padding-left: 10px;">
|
||||
<span>暂无学生提交作业!</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<div class="font_lighter_sidebar" style="padding-left: 200px;">
|
||||
<strong><a href="#" onclick="show()" style="color:#919294;">什么是项目?</a></strong>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 50%">
|
||||
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<div id = "what_is_project_div" style="display: none">
|
||||
<p>项目是一种由用户创建的基于网络的协作空间,能够为个人或小组提供分布式的协同交流和资料管理等方面的支持。</p>
|
||||
<p>项目托管平台:<%= link_to Setting.protocol + "://" + Setting.host_name + "/", home_path %> </p>
|
||||
<%= link_to "我要创建项目",new_project_path(course: 0, project_type: 0), :target => '_blank'%>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% if @homework_list.empty? %>
|
||||
<div class="font_lighter_sidebar" style="padding-left: 10px">
|
||||
暂无学生提交作业!
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id='bidding_project_list'>
|
||||
<%= render :partial => 'homework_list', :locals => {:homework => @homework_list} %>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<!-- fq -->
|
||||
<% is_student = is_cur_course_student(@bid.courses.first) %>
|
||||
<% is_teacher = is_course_teacher(User.current,@bid.courses.first) %>
|
||||
<% is_teacher = is_course_teacher User.current,@bid.courses.first %>
|
||||
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能,2表示未启用 -->
|
||||
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
|
||||
<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %>
|
||||
|
|
@ -8,19 +8,18 @@
|
|||
<table width="100%" valign="center">
|
||||
<tr>
|
||||
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
|
||||
<%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
|
||||
<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
|
||||
User.current.admin? ||
|
||||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
|
||||
(Rails.env.development?) %>
|
||||
</td>
|
||||
</td>
|
||||
<td align="right">
|
||||
<div class="project-search">
|
||||
<% if is_teacher %>
|
||||
<%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
|
||||
<%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
|
||||
<% end %>
|
||||
</div>
|
||||
</td>
|
||||
<div class="project-search">
|
||||
<% if is_teacher %>
|
||||
<%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
|
||||
<%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
|
||||
<% end %>
|
||||
</div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -29,121 +28,76 @@
|
|||
<% @homework_list.each do |homework|%>
|
||||
<table width="660px" border="0" align="center" id="homework_attach_<%= homework.id %>" >
|
||||
<tr>
|
||||
<td style="vertical-align: top;width: 70px" >
|
||||
<table style="text-align: center;width: 100%;table-layout: fixed">
|
||||
<tr>
|
||||
<td title="<%= homework.user.name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td title="<%= homework.user.name %>">
|
||||
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong>
|
||||
<%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user),{:style => "color:#727272"} %>
|
||||
</strong></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
|
||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||
<% if homework.user == User.current || is_teacher %>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
<tr>
|
||||
<td style="width: 300px;">
|
||||
<strong>作业 :</strong>
|
||||
<% if homework.name == nil || homework.name == "" %>
|
||||
<% attachments = homework.attachments.map %>
|
||||
<% for attachment in attachments %>
|
||||
<% if attachments.count > 1 %>
|
||||
<% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %>
|
||||
<% else %>
|
||||
<% homework_filename = attachment.filename %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% homework_filename = homework.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<span></span>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<table width="580px" border="0" style="table-layout: fixed">
|
||||
<tr>
|
||||
<td style="width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<strong>作品名称:</strong>
|
||||
<% if homework.name == nil || homework.name == "" %>
|
||||
<% homework_filename = homework.user.name + "提交的作业" %>
|
||||
<% else %>
|
||||
<% homework_filename = homework.name %>
|
||||
<% end %>
|
||||
<strong title="<%=homework_filename%>">
|
||||
<%= link_to homework_filename , homework_attach_path(homework)%>
|
||||
</strong>
|
||||
</td>
|
||||
<td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||
<strong>合作成员: </strong>
|
||||
<% homework_users = homework_user_of_homework(homework,is_teacher) %>
|
||||
<% if homework.users.count == 0 %>
|
||||
无
|
||||
<% else %>
|
||||
<span title="<%= homework_users%>"><%= homework_users %></span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td rowspan="4" style="text-align: center;vertical-align: middle;width: 30px">
|
||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||
<span class="required">迟交</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<strong>开发项目</strong>:
|
||||
<% if homework.project != nil %>
|
||||
<%= link_to homework.project.name,project_path(homework.project.id)%>
|
||||
<% else %>
|
||||
暂无
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<strong>项目得分:
|
||||
<span style="color: <%= homework.project.nil? ? "#727272" : "#EC6300"%>;">
|
||||
<%= homework.project.nil? ? "N/A" : project_score(homework.project) %>
|
||||
</span>
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<strong>提交文件:
|
||||
<% if is_evaluation || is_teacher%>
|
||||
<%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
|
||||
<% else %>
|
||||
<span class="required">未开启互评功能作业不允许下载</span>
|
||||
<% end %>
|
||||
</strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong>互评得分:
|
||||
<% student_homework_score = student_score_for_homework(homework) %>
|
||||
<span style="color:<%= student_homework_score == "0.00"? "#727272" : "#EC6300"%>;">
|
||||
<% score = student_homework_score == "0.00"? "N/A" : student_homework_score %>
|
||||
<%= score %>
|
||||
</span>
|
||||
<% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%>
|
||||
<%= link_to "学生互评>>",homework_attach_path(homework) %>
|
||||
<% end %>
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<strong>
|
||||
<% if is_evaluation || is_teacher%>
|
||||
<%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
|
||||
<% else %>
|
||||
<%= homework_filename %>
|
||||
<% end %>
|
||||
</strong>
|
||||
</td>
|
||||
<td style="vertical-align: top">
|
||||
<% if is_student %>
|
||||
<% if is_evaluation %>
|
||||
<%= link_to "互评>>" , homework_attach_path(homework)%>
|
||||
<% else %>
|
||||
<%= link_to "查看详细" , homework_attach_path(homework)%>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if is_teacher %>
|
||||
<%= link_to "综评>>" , homework_attach_path(homework)%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;width: 200px;">
|
||||
<% if is_evaluation || is_teacher%>
|
||||
<%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<strong>终评得分:
|
||||
<% totle_homework_score = score_for_homework(homework) %>
|
||||
<span style="color:<%= totle_homework_score == "0.00"? "#727272" : "#EC6300"%> ;">
|
||||
<% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %>
|
||||
<%= score %>
|
||||
</span>
|
||||
<% if is_teacher %>
|
||||
<%= link_to "教师评分>>",homework_attach_path(homework) %>
|
||||
<% end %>
|
||||
</strong>
|
||||
</td>
|
||||
<td colspan="1" valign="top" style="width: 300px">
|
||||
<strong>发布人: <%= link_to ( is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%></strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong>作业评分:</strong>
|
||||
|
||||
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||
<span class="required">迟交</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<% if User.current.member_of?(@bid.courses.first) %>
|
||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.student_id%></strong>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
|
||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||
<% if homework.user == User.current || is_teacher %>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@
|
|||
<!-- <div class="pagination" style="border-bottom: 1px solid rgb(223,223,223); width: 95%; margin-left: 2%; margin-top: 15px" >
|
||||
<ul style="margin-right:0px">
|
||||
<li>
|
||||
<%#= link_to l(:label_sort_by_time), calls_path(:bid_sort_type => '0') %>
|
||||
<%= link_to l(:label_sort_by_time), calls_path(:bid_sort_type => '0') %>
|
||||
</li>
|
||||
<li>
|
||||
<%#= link_to l(:label_sort_by_active), calls_path(:bid_sort_type => '1') %>
|
||||
<%= link_to l(:label_sort_by_active), calls_path(:bid_sort_type => '1') %>
|
||||
</li>
|
||||
<!-- <li>
|
||||
<%#= link_to l(:label_sort_by_influence), calls_path(:bid_sort_type => '2') %>
|
||||
<%= link_to l(:label_sort_by_influence), calls_path(:bid_sort_type => '2') %>
|
||||
</li> -->
|
||||
<!-- </ul>
|
||||
</div> -->
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div style="margin-left: 20px;">
|
||||
<span class="portrait"><%= image_tag(url_to_avatar(@bid.author), :class => "avatar")%></span>
|
||||
<span class="body">
|
||||
<h3><%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%>:<%= link_to(@bid.name,respond_path(@bid)) %></h3>
|
||||
<h3><%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%>:<%= @bid.name %></h3>
|
||||
<% if @bid.reward_type.nil? or @bid.reward_type == 1%>
|
||||
<p>
|
||||
<strong><%= l(:label_bids_reward_method) %><span class="bonus"><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= @bid.budget %></span></strong>
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@
|
|||
<strong>
|
||||
<%= l(:label_contest_user) %>
|
||||
<% unless c_project.user.nil? %>
|
||||
<!-- modified by zjc 添加超链接 -->
|
||||
<%= link_to c_project.user.lastname + c_project.user.firstname,user_path(c_project.user) %>
|
||||
<%= c_project.user.lastname %><%= c_project.user.firstname %>
|
||||
<% end %>
|
||||
</strong>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<div class="project-search" style="float: right">
|
||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||
<%= hidden_field_tag 'project_type', params[:project_type] %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
|
||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -259,10 +259,7 @@
|
|||
<span><strong><%= l(:label_attendingcontest_time) %>
|
||||
:</strong><%= format_time c_project.created_at %></span>
|
||||
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
|
||||
<!-- modified by zjc 添加超链接 -->
|
||||
<% unless c_project.nil? || c_project.user.nil? %>
|
||||
:</strong><%= link_to c_project.user.name,user_path(c_project.user) %></span>
|
||||
<% end %>
|
||||
:</strong><%= c_project.user.name %></span>
|
||||
</div>
|
||||
|
||||
<div style="padding-left: 68px">
|
||||
|
|
@ -296,17 +293,13 @@
|
|||
<span><strong><%= l(:label_attendingcontest_time) %>
|
||||
:</strong><%= format_time c_softapplication.created_at %></span>
|
||||
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
|
||||
<!-- modified by zjc 添加超链接 -->
|
||||
<% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %>
|
||||
:</strong><%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %></span>
|
||||
<% end %>
|
||||
:</strong><%= c_softapplication.softapplication.user.name %></span>
|
||||
</div>
|
||||
|
||||
<!--获奖及教师评奖-->
|
||||
<div style="padding-left: 18px; padding-bottom: 5px">
|
||||
<% score = c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_f %>
|
||||
<span style="padding-left: 50px"><strong><%= l(:label_final_scores) %>
|
||||
:</strong></span><span style="color: red"><%= format("%.2f" , score) %>
|
||||
:</strong></span><span style="color: red"><%= c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_i.to_s %>
|
||||
分</span>
|
||||
<span style="padding-left: 334px">
|
||||
<td>
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
<% @admin = @course.course_infos%>
|
||||
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
||||
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
||||
<% unless @course.teacher.user_extensions.school.nil? %>
|
||||
<%= link_to @course.teacher.user_extensions.school.try(:name), school_course_list_path(@course.teacher.user_extensions.school) %>
|
||||
<% end %>
|
||||
<%# unless @course.course_extra.school.nil? %>
|
||||
<%= @course.teacher.user_extensions.school.try(:name) %>
|
||||
<%# end %>
|
||||
<% end %>
|
||||
</p>
|
||||
<p >
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
<% object = [] %>
|
||||
<% object << 'course' %>
|
||||
<% object << 'course' %>
|
||||
<%= error_messages_for object %>
|
||||
|
||||
|
||||
|
|
@ -93,8 +94,7 @@
|
|||
<option value = '2014'>2014</option>
|
||||
<option value = '2015'>2015</option>
|
||||
<option value = '2016'>2016</option>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table>
|
||||
</p>
|
||||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% elsif @course.time == 2009 %>
|
||||
<p><table><tr><td class="info" align="right" style="width: 86px"><strong><%= l(:label_term) %><span class="required"> * </span></strong></td>
|
||||
|
|
@ -237,8 +237,7 @@
|
|||
<option value = '2017'>2017</option>".html_safe %></td></tr></table></p>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %></td>
|
||||
<td>
|
||||
<% unless @course.nil? %>
|
||||
<% if @course.term == l(:label_spring) %>
|
||||
|
|
@ -278,8 +277,7 @@
|
|||
|
||||
<% end %>
|
||||
|
||||
<% end %></td></tr></table>
|
||||
</p>
|
||||
<% end %></td></tr></table></p>
|
||||
<!-- end -->
|
||||
|
||||
|
||||
|
|
@ -294,12 +292,12 @@
|
|||
|
||||
|
||||
|
||||
<!-- <p style="margin-left:-10px;"><%#= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
||||
<!-- <p style="margin-left:-10px;"><%= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
||||
<p style="margin-left:-10px;"><label for="course[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@course.password %>" size="60" name="course[password]"></p>
|
||||
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
||||
<% end %>
|
||||
|
||||
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%#= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
|
||||
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
|
||||
<p style="margin-left:-20px;padding-right: 20px;"><label for="course_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40" ><%=@course.description%></textarea></span></p>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,17 +25,14 @@
|
|||
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %></p>
|
||||
|
||||
<p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %></p>
|
||||
<!-- <p><%#= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '3'>#{l(:label_bids_credit)}</option><option value = '2'>#{l(:label_reward_1)}</option>".html_safe,
|
||||
<!-- <p><%= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '3'>#{l(:label_bids_credit)}</option><option value = '2'>#{l(:label_reward_1)}</option>".html_safe,
|
||||
:onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %>
|
||||
<%#= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
|
||||
<%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
|
||||
</p> -->
|
||||
<% time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') %>
|
||||
<p><%= f.text_field(:deadline, :required => true, :size => 60, :style => "width:150px;",:value => "#{time}") %><%= calendar_for('bid_deadline')%>
|
||||
<p><%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>
|
||||
</p>
|
||||
<p><%= f.select :is_evaluation, is_evaluation_option %>
|
||||
</p>
|
||||
<p><%= f.select :proportion, proportion_option %>
|
||||
</p>
|
||||
<p><%= hidden_field_tag 'course_id', @course.id %>
|
||||
</p>
|
||||
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@
|
|||
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||
<% end %>
|
||||
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
|
||||
<% if @canShowCode %>
|
||||
<%= content_tag "div", link_to(member.user.show_name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||
<% else %>
|
||||
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||
<% end %>
|
||||
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||
<!--teacher's code disapeared moified by huang-->
|
||||
|
||||
<% unless member.user.user_extensions.identity ==0 %>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
<% if @save_flag %>
|
||||
<% if Rails.env.development? %>
|
||||
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
|
||||
<% end %>
|
||||
$('#content-title-top-div').html("<%= j(render partial: 'users/my_course_ex', :locals => {:memberships => @memberships,:user=>@user,
|
||||
:memberships_doing=>@memberships_doing,:memberships_done=>@memberships_done} )%>")
|
||||
$('#finish_course_<%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>")
|
||||
<% if Rails.env.development? %>
|
||||
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
|
||||
<% end %>
|
||||
$('#finish_course_<%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>")
|
||||
<% else %>
|
||||
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
||||
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
|
||||
<table width="940px">
|
||||
<tr>
|
||||
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_all) %></td>
|
||||
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>
|
||||
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
||||
<td rowspan="2">
|
||||
<% if User.current.logged?%>
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index' %> </a></td>
|
||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_all), :controller => 'courses', :action => 'index' %></td>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index', :course_type => 1 %> </a></td>
|
||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index', :course_type => 1 %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<h3><%=l(:label_course_new_homework)%></h3>
|
||||
|
||||
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
||||
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework'} do |f| %>
|
||||
<div class="box tabular">
|
||||
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create), :class => "enterprise" %>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host() + "/courses", :controller => 'courses', :action => 'index'%> </a></td>
|
||||
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/courses", :controller => 'courses', :action => 'index'%> </a></td>
|
||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div>
|
||||
<table class="underline-evreycontent" style="font-size: 14px;">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50"><%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %></td>
|
||||
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(e.event_author), :class => "avatar")%></td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
<tr>
|
||||
|
|
@ -19,37 +19,29 @@
|
|||
<strong> <%= h(e.event_title) if @course.nil? || (e.course != nil && @course.id != e.course.id) %></strong>
|
||||
<span class="font_lighter">
|
||||
<% if @canShowRealName %>
|
||||
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
|
||||
(<%= link_to_user(e.event_author, @canShowRealName) if e.respond_to?(:event_author) %>
|
||||
)
|
||||
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>)
|
||||
<% else %>
|
||||
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
|
||||
<% end %>
|
||||
|
||||
<%= l(:label_new_activity) %> </span>
|
||||
|
||||
|
||||
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px">
|
||||
<td colspan="2" width="580px" >
|
||||
<p class="info-break">
|
||||
<%= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
|
||||
<%= h(truncate(strip_tags(e.event_description).gsub(/ /,' '), length: 30, omission:'...')) %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><span class="font_lighter"> <%= l :label_activity_time %>
|
||||
: <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %></span>
|
||||
</td>
|
||||
<td align="left"><span class="font_lighter"> <%= l :label_activity_time %>: <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %></span></td>
|
||||
<% if e.event_type == "issue" %>
|
||||
<td align="right">
|
||||
<span> <%= link_to l(:label_find_all_comments), issue_path(e.id) %> </span><span class="font_lighter"><%= l(:label_comments_count, :count => e.journals.count) %></span>
|
||||
</td>
|
||||
<td align="right"><span> <%= link_to l(:label_find_all_comments), issue_path(e) %> </span><span class="font_lighter"><%= l(:label_comments_count, :count => e.journals.count)%></span></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -57,47 +49,60 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Added by Longjun 在最后一页显示创建信息 -->
|
||||
<% if format_date(day) == format_date(@date_to - @days) %>
|
||||
<h1>Test</h1>
|
||||
<div >
|
||||
<table width="660">
|
||||
<tr>
|
||||
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||
<td colspan="2">
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td > <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @course.name %><strong> !</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@course.created_on) %>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @events_pages%>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="font_description">
|
||||
<table width="660">
|
||||
<tr>
|
||||
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||
<td colspan="2">
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td >
|
||||
<%
|
||||
#判断是否显示真名
|
||||
if @canShowRealName
|
||||
%>
|
||||
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>(<%= link_to (h @user.try(:realname)), user_path(@user) if @user %>)
|
||||
<% else %>
|
||||
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>
|
||||
<% end %>
|
||||
<%= l(:label_user_create_project) %> <%= link_to @course.name %><strong> !</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@course.created_at) %>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="font_description">
|
||||
<table width="660">
|
||||
<tr>
|
||||
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||
<td colspan="2">
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td>
|
||||
<%
|
||||
#判断是否显示真名
|
||||
if @canShowRealName
|
||||
%>
|
||||
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>
|
||||
(<%= link_to (h @user.try(:realname)), user_path(@user) if @user %>)
|
||||
<% else %>
|
||||
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>
|
||||
<% end %>
|
||||
<%= l(:label_user_create_project) %> <%= link_to @course.name %>
|
||||
<strong> !</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font_lighter" style="float: right"><%= l :label_create_time %>
|
||||
: <%= format_time(@course.created_at) %>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @events_pages %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<%= text_field_tag(:attach_search) %>
|
||||
<%#= submit_tag("Search") %>
|
||||
<% end -%>
|
||||
<%= form_tag course_attach_relation_path(:format => 'js'),
|
||||
<%= form_tag attach_relation_path(:format => 'js'),
|
||||
method: :post,
|
||||
remote: true,
|
||||
id: "relation_file_form",
|
||||
|
|
|
|||
|
|
@ -13,25 +13,18 @@
|
|||
<%= select_tag "version_id", content_tag('option', '') +
|
||||
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
|
||||
</td>
|
||||
<% if attachmenttypes.any? %>
|
||||
<td><%= l(:attachment_type) %></label></td>
|
||||
<td>
|
||||
<%= select_tag "attachment_type",
|
||||
options_from_collection_for_select(attachmenttypes, "id",
|
||||
"typeName", 2), {style: 'width:100px'} %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>
|
||||
<% if attachmenttypes.any? %>
|
||||
<%= l(:attachment_type) %></label>
|
||||
<%= select_tag "attachment_type",
|
||||
options_from_collection_for_select(attachmenttypes, "id",
|
||||
"typeName", 2), {style: 'width:100px'} %>
|
||||
<% end %>
|
||||
</p>
|
||||
<td><p></p></td> <td></td>
|
||||
<% end %>
|
||||
|
||||
<% if attachmenttypes.any? %>
|
||||
<td><%= l(:attachment_type) %></label></td>
|
||||
<td>
|
||||
<%= select_tag "attachment_type",
|
||||
options_from_collection_for_select(attachmenttypes, "id",
|
||||
"typeName", 2), {style: 'width:100px'} %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
<div id="share_new" style = "width: 500px; margin:0 auto; " >
|
||||
<%= labelled_form_for(@forum) do |f| %>
|
||||
<% if @forum.errors.any? %>
|
||||
<!--<div id="error_explanation">
|
||||
<h2><#%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<#% @forum.errors.full_messages.each do |msg| %>
|
||||
<li><#%= msg %></li>
|
||||
<#% end %>
|
||||
<% @forum.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div> -->
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="actions" style="margin:10px">
|
||||
<div class="field">
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@
|
|||
<h3><%=l(:label_memo_new)%></h3>
|
||||
<% if User.current.logged? %>
|
||||
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
|
||||
<!--<#% if @memo.errors.any? %>
|
||||
<% if @memo.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><#%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
|
||||
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<#% @memo.errors.full_messages.each do |msg| %>
|
||||
<li><#%= msg %></li>
|
||||
<#% end %>
|
||||
<% @memo.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<#% end %> -->
|
||||
<% end %>
|
||||
<div class="actions" style="max-width:680px">
|
||||
<p><%= f.text_field :subject, :required => true%></p>
|
||||
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ body table tr td span6 {
|
|||
<td><p >在桌面上点击鼠标右键,选择TortoiseGit的Settings进行设置</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">Name和Email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到,<span5> 其中的name和email要和<%= Setting.host_name %>上的登陆名和邮箱保持一致</span5>
|
||||
<td align="left">Name和Email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到,<span5> 其中的name和email要和forge.trustie.net上的登陆名和邮箱保持一致</span5>
|
||||
,方便代码贡献统计 )。 </td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -313,7 +313,7 @@ body table tr td span6 {
|
|||
<td><p ><span>$git config --global user.name “your_name”</span></p>
|
||||
<p><span>$git config --global user.email “your_email” </span> </p>
|
||||
<p>Name和Email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到,
|
||||
<span5> 其中的name和email要和<%= Setting.host_name %>上的登陆名和密码保持一致</span5>
|
||||
<span5> 其中的name和email要和forge.trustie.net上的登陆名和密码保持一致</span5>
|
||||
,方便代码贡献统计 )。</p></td>
|
||||
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ body table tr td span6 {
|
|||
<table width="900" border="0">
|
||||
<tr>
|
||||
<td><p>Right-click on the desktop and select the "Settings" in the "TortoiseGit"</p>
|
||||
<p>User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository, <span5> the name and email must be the same with login name and email you registed in the <%= Setting.host_name %></span5>
|
||||
<p>User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository, <span5> the name and email must be the same with login name and email you registed in the forge.trustie.net</span5>
|
||||
). </p>
|
||||
<p>Then you can customize the "Context Menu":</p>
|
||||
<p>Please check the "<span>Clone</span>","<span>Sync</span>" and "<span>Commit</span>" options in the "<span>Context Menu</span>",</p>
|
||||
|
|
@ -306,7 +306,7 @@ body table tr td span6 {
|
|||
<td><p><span>$git config --global user.name “your_name”M</span></p>
|
||||
<p><span>$git config --global user.email “your_email”</span> </p>
|
||||
<p>User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository,
|
||||
<span5> the name and email must be the same with login name and email you registed in the <%= Setting.host_name %></span5>
|
||||
<span5> the name and email must be the same with login name and email you registed in the forge.trustie.net</span5>
|
||||
). </p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,23 @@
|
|||
<% is_teacher = is_course_teacher User.current,homework.bid.courses.first %>
|
||||
<% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %>
|
||||
<% stars = homework.rates(:quality).where("rater_id = #{comprehensive_evaluation.first.user.id}").select("stars").first %>
|
||||
<div style="height: 100px; padding-bottom: 10px">
|
||||
<div style="font-size: 15px">
|
||||
<strong>作业综评:</strong>
|
||||
<%= render :partial => 'show_score', locals: {:stars => teaher_score} %>
|
||||
<span class="user" style="font-size: 15px">
|
||||
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
|
||||
style="height: 15px; width: 100px; overflow: hidden; z-index: 1; position: relative;">
|
||||
<% if stars != nil %>
|
||||
<div class="jRatingColor" style="width: <%=stars.stars * 2 * 10 %>%;"></div>
|
||||
<% else %>
|
||||
<div class="jRatingColor" style="width: 0px;"></div>
|
||||
<% end %>
|
||||
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
|
||||
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
|
||||
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<div style="font-size: 14px;">
|
||||
<div style="margin-left: 20px;margin-bottom: 10px;margin-top: 10px;"> <%= comprehensive_evaluation.first.notes%> </div>
|
||||
|
|
@ -17,7 +31,7 @@
|
|||
</div>
|
||||
<%= render :partial => 'evaluation', :locals => {:homework => homework} %>
|
||||
<div>
|
||||
<%= render :partial => 'evaluation_add_jour', :locals => {:homework_attach => homework, :sta => 0,:is_comprehensive_evaluation => 1} %>
|
||||
<%= render :partial => 'addjour', :locals => {:homework_attach => homework, :sta => 0,:is_comprehensive_evaluation => 1} %>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
<style>
|
||||
input[type="submit"].bid_btn {
|
||||
vertical-align: middle;
|
||||
width: 60px;/*modified by ming*/
|
||||
height: 25px;
|
||||
line-height: 19px;
|
||||
font-size: 14px;
|
||||
color: rgb(0, 0, 0);
|
||||
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
|
||||
padding: 0px 0px 4px 0px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid rgb(148, 148, 148);
|
||||
box-shadow: none;
|
||||
text-shadow: none;
|
||||
margin-top: -10px;
|
||||
/*margin-right: -4px;*/
|
||||
}
|
||||
input[type="button"].bid_btn {
|
||||
width: 60px;/*modified by ming*/
|
||||
height: 25px;
|
||||
line-height: 19px;
|
||||
font-size: 14px;
|
||||
color: rgb(0, 0, 0);
|
||||
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
|
||||
padding: 0px 0px 4px 0px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid rgb(148, 148, 148);
|
||||
box-shadow: none;
|
||||
text-shadow: none;
|
||||
margin-top: -10px;
|
||||
margin-right: -2px;
|
||||
}
|
||||
textarea:focus {
|
||||
border: #d5dee9 1px solid;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
function clearInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
if (text.val() == content) {
|
||||
$('#' + id).val('');
|
||||
}
|
||||
}
|
||||
|
||||
function showInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
if (text.val() == '') {
|
||||
$('#' + id).val(content);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<%= form_for('new_form', :method => :post,
|
||||
:url => {:controller => 'homework_attach',
|
||||
:action => 'comprehensive_evaluation_jour',
|
||||
:jour_id => homework_attach.id,
|
||||
:is_comprehensive_evaluation => is_comprehensive_evaluation,
|
||||
:sta => sta}) do |f|%>
|
||||
|
||||
<div id = 'pre_show'>
|
||||
<%= render :partial => 'words/pre_show', :locals => {:content => @content} %>
|
||||
</div>
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<table border="0" width="525px" align="center" >
|
||||
<tr>
|
||||
<td><%= f.text_area 'user_message', :rows => 3, :cols => 65, :value => "#{l(:label_leave_a_message)}",
|
||||
:onfocus => "clearInfo('new_form_user_message','#{l(:label_leave_a_message)}')",
|
||||
:onblur => "showInfo('new_form_user_message','#{l(:label_leave_a_message)}')",
|
||||
:style => "resize: none;", :class => 'noline'%></td>
|
||||
</tr>
|
||||
</table>
|
||||
<%= f.text_field :reference_user_id, :style=>"display:none"%>
|
||||
<table border="0" width="525px" align="center">
|
||||
<tr>
|
||||
<td align="right"> <%= submit_tag l(:button_leave_meassge),
|
||||
:name => nil , :class => "enterprise",
|
||||
:onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||
:onmouseover => "this.style.backgroundPosition = 'left -31px'"%>
|
||||
<%= submit_tag l(:button_clear), :name => nil, :class => "enterprise",
|
||||
:onclick => "clearMessage('new_form_user_message');",
|
||||
:onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||
:onmouseover => "this.style.backgroundPosition = 'left -31px'" %> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<% else %>
|
||||
<div style="font-size: 14px;margin:10px;text-align: center">
|
||||
<%= l(:label_user_login_tips) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<span class="user" style="font-size: 15px">
|
||||
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
|
||||
style="height: 15px; width: 100px; overflow: hidden; z-index: 1; position: relative;">
|
||||
<% if stars != nil %>
|
||||
<div class="jRatingColor" style="width: <%=stars.to_f * 20 %>%;"></div>
|
||||
<% else %>
|
||||
<div class="jRatingColor" style="width: 0px;"></div>
|
||||
<% end %>
|
||||
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
|
||||
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
|
||||
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<% if @add_jour.is_comprehensive_evaluation == 1 %>
|
||||
$('#comprehensive_evaluation').html('<%= escape_javascript(render(:partial => 'comprehensive_evaluation',
|
||||
:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework,:teaher_score => @teaher_score} )) %>');
|
||||
:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} )) %>');
|
||||
<% else %>
|
||||
$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false,:homework => @homework} )) %>');
|
||||
$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>');
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<script type="text/javascript">
|
||||
function switchTab(ProTag) {
|
||||
var display_index = 3 - ProTag;
|
||||
$("#tab" + ProTag).attr("class","selected");
|
||||
$("#tab" + display_index).attr("class","");
|
||||
$("#content" + ProTag).show();
|
||||
$("#content" + display_index).hide();
|
||||
document.getElementById("tab" + ProTag).className = "selected";
|
||||
document.getElementById("tab" + display_index).className = "";
|
||||
document.getElementById("content" + ProTag).style.display = "";
|
||||
document.getElementById("content" + display_index).style.display = "none";
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -42,22 +42,11 @@
|
|||
<div class="box" id="content1">
|
||||
<%= form_for(@homework) do |f|%>
|
||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||
<strong>标 题 <span style="color: red">*</span>:</strong>
|
||||
<strong>标 题:</strong>
|
||||
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
|
||||
</p>
|
||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||
<strong>提交项目 :</strong>
|
||||
<% if @homework.project.nil? %>
|
||||
<%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%>
|
||||
<% else %>
|
||||
<%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),:name => "project_id", :required => true%>
|
||||
<% end %>
|
||||
|
||||
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
|
||||
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
|
||||
</p>
|
||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||
<strong style="vertical-align: top">描 述 :</strong>
|
||||
<strong style="vertical-align: top">描 述:</strong>
|
||||
<span style="margin-left:-10px;padding-right: 20px;">
|
||||
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -23,17 +23,11 @@
|
|||
:bid_id => @bid
|
||||
}) do |f|%>
|
||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||
<strong>标 题 <span style="color: red">*</span>:</strong>
|
||||
<strong>标 题:</strong>
|
||||
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
||||
</p>
|
||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||
<strong>提交项目 :</strong>
|
||||
<%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true, :style => "width:490px;"%>
|
||||
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
|
||||
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
|
||||
</p>
|
||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||
<strong style="vertical-align: top">描 述 :</strong>
|
||||
<strong style="vertical-align: top">描 述:</strong>
|
||||
<span style="margin-left:-10px;padding-right: 20px;">
|
||||
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
|
||||
</td>
|
||||
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
|
||||
所属任务:<%= link_to(@homework.bid.name, course_for_bid_path(@homework.bid))%>
|
||||
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td style=" padding-left: 40px">平均评分:
|
||||
<%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
|
||||
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
|
||||
</td>
|
||||
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
|
||||
</tr>
|
||||
|
|
@ -110,12 +110,17 @@
|
|||
</div>
|
||||
</div>
|
||||
<div style="float: left; padding-left: 100px; padding-top:35px ">
|
||||
<% score = @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
|
||||
<div style="text-align: center">最终得分</div>
|
||||
<div style="padding-top: 1px; font-size: 15px; color: blue;text-align: center">
|
||||
<%= @totle_score %>分
|
||||
<% if score == "" %>
|
||||
0分
|
||||
<% else %>
|
||||
<%= score %>分
|
||||
<% end %>
|
||||
</div>
|
||||
<div style="padding-top: 3px">
|
||||
<%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
|
||||
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
|
||||
</div>
|
||||
</div>
|
||||
<div style="float: left; padding-left: 100px; padding-top:35px ">
|
||||
|
|
@ -132,7 +137,7 @@
|
|||
|
||||
<!-- 作业综评 -->
|
||||
<div id="comprehensive_evaluation">
|
||||
<%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score} %>
|
||||
<%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} %>
|
||||
</div>
|
||||
|
||||
<div class="underline-contests_one"></div>
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@
|
|||
|
||||
<%= watcher_link(@issue, User.current) %>
|
||||
<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:add_issues, @project) %>
|
||||
<%= link_to l(:button_delete), issue_path(@issue.id), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %>
|
||||
<%= link_to l(:button_delete), issue_path(@issue), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -28,12 +28,11 @@
|
|||
<ul class="issue_list">
|
||||
<% unless issue.author.nil? || issue.author.name == "Anonymous" %>
|
||||
<ul class="list-group-item-meta">
|
||||
<span> <%= link_to issue.author.name, user_path(issue.author), :class => "bid_user_u" %></span>
|
||||
<%= l(:label_post_on)%> <% a = [] %>
|
||||
<span> <%= link_to issue.author.name, user_path(issue.author), :class => "bid_user_u" %></span><%= l(:label_post_on)%> <% a = [] %>
|
||||
<% a << column_content[1] %>
|
||||
<%# a << "##{column_content[0]}" << "(#{raw column_content[2]}):" << column_content[4] %>
|
||||
<% a << "#{issue.source_from}" << "(#{raw column_content[2]}):" << column_content[4] %>
|
||||
<%= link_to a.join(' '), issue_path(issue.id), :class => "issue-link" , :target =>"_blank"%>
|
||||
<%= link_to a.join(' '), issue_path(issue), :class => "issue-link" %>
|
||||
</ul>
|
||||
<% end -%>
|
||||
<ul class="list-group-item-meta">
|
||||
|
|
@ -47,7 +46,7 @@
|
|||
<% end %>
|
||||
<%= l(:label_updated_time_on, format_date(issue.updated_on)).html_safe %>
|
||||
<div class="find-comment-class">
|
||||
<span><%= link_to l(:label_find_all_comments), issue_path(issue.id) %></span><%= l(:label_comments_count, :count => issue.journals.all.count) %>
|
||||
<span><%= link_to l(:label_find_all_comments), issue_path(issue) %></span><%= l(:label_comments_count, :count => issue.journals.all.count) %>
|
||||
</div>
|
||||
</ul>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
<tr id="issue-<%= h(issue.id) %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %>">
|
||||
<td class="id">
|
||||
<%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;', :id => nil) %>
|
||||
<%= link_to issue.id, issue_path(issue.id) %>
|
||||
<%= link_to issue.id, issue_path(issue) %>
|
||||
</td>
|
||||
<td class="project"><%= link_to_project(issue.project) %></td>
|
||||
<td class="tracker"><%=h issue.tracker %></td>
|
||||
<td class="subject">
|
||||
<%= link_to truncate(issue.subject, :length => 60), issue_path(issue.id) %> (<%=h issue.status %>)
|
||||
<%= link_to truncate(issue.subject, :length => 60), issue_path(issue) %> (<%=h issue.status %>)
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ end %>
|
|||
|
||||
<div style="clear: both;"></div>
|
||||
<% if @issue.editable? %>
|
||||
<div id="update">
|
||||
<div id="update" style="display:none;">
|
||||
<h3><%= l(:button_update) %></h3>
|
||||
<%= render :partial => 'edit' %>
|
||||
</div>
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue