\ No newline at end of file
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 8f87767ed..b493277fd 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -394,6 +394,27 @@ function show_bid_dead_line(year,month,day,divname)
+ ""
+ "
\ No newline at end of file
diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb
index f9d3f8b70..87977c6a9 100644
--- a/app/views/homework_common/edit.html.erb
+++ b/app/views/homework_common/edit.html.erb
@@ -8,7 +8,7 @@
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb
new file mode 100644
index 000000000..148379f9e
--- /dev/null
+++ b/app/views/homework_common/next_step.html.erb
@@ -0,0 +1,31 @@
+<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
+<%= error_messages_for 'homework_common' %>
+
diff --git a/db/migrate/20150708085629_change_studen_work_desc.rb b/db/migrate/20150708085629_change_studen_work_desc.rb
new file mode 100644
index 000000000..af3c25671
--- /dev/null
+++ b/db/migrate/20150708085629_change_studen_work_desc.rb
@@ -0,0 +1,9 @@
+class ChangeStudenWorkDesc < ActiveRecord::Migration
+ def up
+ change_column :student_works,:description,:text,:limit => 4294967295
+ end
+
+ def down
+ change_column :student_works,:description,:text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4016cd6a9..539dd95d3 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20150708025533) do
+ActiveRecord::Schema.define(:version => 20150708085629) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -1222,18 +1222,18 @@ ActiveRecord::Schema.define(:version => 20150708025533) do
create_table "student_works", :force => true do |t|
t.string "name"
- t.text "description"
+ t.text "description", :limit => 2147483647
t.integer "homework_common_id"
t.integer "user_id"
t.float "final_score"
t.float "teacher_score"
t.float "student_score"
t.float "teaching_asistant_score"
- t.integer "project_id", :default => 0
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "late_penalty", :default => 0
- t.integer "absence_penalty", :default => 0
+ t.integer "project_id", :default => 0
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "late_penalty", :default => 0
+ t.integer "absence_penalty", :default => 0
end
create_table "student_works_evaluation_distributions", :force => true do |t|
From eb1976efbbeb5adaafe9a6154ef32659ef86562a Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 9 Jul 2015 10:38:44 +0800
Subject: [PATCH 026/100] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=EF=BC=8C=E6=9C=80=E7=BB=88=E8=AF=84=E5=88=86=E7=9A=84=E8=AE=A1?=
=?UTF-8?q?=E7=AE=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/student_work_controller.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 0efa0aa66..b6f69a4da 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -190,8 +190,10 @@ class StudentWorkController < ApplicationController
if @work.student_score.nil?
@work.final_score = @work.teaching_asistant_score
else
- final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")
- final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}"))
+ ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual
+ ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing
+ final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
+ final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
final_score = final_ta_score + final_s_score
@work.final_score = format("%.2f",final_score.to_f)
end
From 24d6c8e17e83b80d552864490b4dc9527a009831 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Thu, 9 Jul 2015 15:20:59 +0800
Subject: [PATCH 027/100] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0question=5Fid=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
db/migrate/20150709071731_add_question_id_to_homework.rb | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 db/migrate/20150709071731_add_question_id_to_homework.rb
diff --git a/db/migrate/20150709071731_add_question_id_to_homework.rb b/db/migrate/20150709071731_add_question_id_to_homework.rb
new file mode 100644
index 000000000..d1be59431
--- /dev/null
+++ b/db/migrate/20150709071731_add_question_id_to_homework.rb
@@ -0,0 +1,9 @@
+class AddQuestionIdToHomework < ActiveRecord::Migration
+ def up
+ add_column :homework_detail_programings, :question_id, :integer
+ end
+
+ def down
+ remove_column :homework_detail_programings, :question_id
+ end
+end
From 5c011fd3429b6df35f1ee4178bf1e9291e7247ba Mon Sep 17 00:00:00 2001
From: yutao <283765470@qq.com>
Date: Thu, 9 Jul 2015 15:27:49 +0800
Subject: [PATCH 028/100] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/my_controller.rb | 24 +
app/controllers/users_controller.rb | 283 +++-
app/controllers/watchers_controller.rb | 7 +-
app/helpers/users_helper.rb | 155 +++
app/views/avatar/upload.js.erb | 6 +-
app/views/courses/finishcourse.js.erb | 10 +-
app/views/layouts/_base_footer_new.html.erb | 13 +
app/views/layouts/_base_header_new.html.erb | 76 +
app/views/layouts/_user_fans_list.html.erb | 12 +
app/views/layouts/_user_watch_btn.html.erb | 8 +
app/views/layouts/_user_watch_list.html.erb | 11 +
app/views/layouts/base_users_new.html.erb | 337 +++++
app/views/my/account.html.erb | 1227 +++++++----------
app/views/my/clear_user_avatar_temp.js.erb | 7 +
app/views/my/save_user_avatar.js.erb | 2 +
app/views/users/_course_form.html.erb | 118 +-
app/views/users/_user_fans_item.html.erb | 50 +
app/views/users/show.html.erb | 968 +++++--------
.../users/user_course_activities.html.erb | 12 +
app/views/users/user_courses.html.erb | 62 +-
app/views/users/user_courses4show.html.erb | 14 +
app/views/users/user_fanslist.html.erb | 74 +-
app/views/users/user_feedback4show.html.erb | 22 +
app/views/users/user_projects.html.erb | 118 +-
app/views/users/user_projects4show.html.erb | 14 +
app/views/watchers/_set_watcher.js.erb | 63 +-
app/views/words/destroy.js.erb | 6 +
config/routes.rb | 7 +
public/images/pic_uersall.png | Bin 0 -> 9946 bytes
public/stylesheets/leftside_new.css | 66 +
public/stylesheets/public_new.css | 430 ++++++
public/stylesheets/users.css | 127 ++
32 files changed, 2673 insertions(+), 1656 deletions(-)
create mode 100644 app/views/layouts/_base_footer_new.html.erb
create mode 100644 app/views/layouts/_base_header_new.html.erb
create mode 100644 app/views/layouts/_user_fans_list.html.erb
create mode 100644 app/views/layouts/_user_watch_btn.html.erb
create mode 100644 app/views/layouts/_user_watch_list.html.erb
create mode 100644 app/views/layouts/base_users_new.html.erb
create mode 100644 app/views/my/clear_user_avatar_temp.js.erb
create mode 100644 app/views/my/save_user_avatar.js.erb
create mode 100644 app/views/users/_user_fans_item.html.erb
create mode 100644 app/views/users/user_course_activities.html.erb
create mode 100644 app/views/users/user_courses4show.html.erb
create mode 100644 app/views/users/user_feedback4show.html.erb
create mode 100644 app/views/users/user_projects4show.html.erb
create mode 100644 public/images/pic_uersall.png
create mode 100644 public/stylesheets/leftside_new.css
create mode 100644 public/stylesheets/public_new.css
create mode 100644 public/stylesheets/users.css
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 69d8bc3a6..84e2e7d35 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -25,6 +25,7 @@ class MyController < ApplicationController
helper :issues
helper :users
helper :custom_fields
+ helper :user_score
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
'issuesreportedbyme' => :label_reported_issues,
@@ -88,6 +89,23 @@ class MyController < ApplicationController
end
end
+ def clear_user_avatar_temp
+ @user = User.current
+ diskfile = disk_filename('User', @user.id)
+ diskfile1 = diskfile + 'temp'
+ File.delete(diskfile1) if File.exist?(diskfile1)
+ end
+ def save_user_avatar
+ @user = User.current
+ diskfile = disk_filename('User', @user.id)
+ diskfile1 = diskfile + 'temp'
+ begin
+ FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
+ ensure
+ File.delete(diskfile1) if File.exist?(diskfile1)
+ end
+ end
+
# Edit user's account
def account
@user = User.current
@@ -119,6 +137,8 @@ class MyController < ApplicationController
@se.identity = params[:identity].to_i if params[:identity]
@se.technical_title = params[:technical_title] if params[:technical_title]
@se.student_id = params[:no] if params[:no]
+ @se.brief_introduction = params[:brief_introduction]
+ @se.description = params[:description]
if @user.save && @se.save
# 头像保存
@@ -137,6 +157,7 @@ class MyController < ApplicationController
File.delete(diskfile1) if File.exist?(diskfile1)
end
+ render :layout=>'base_users_new'
end
# Destroys user's account
@@ -159,6 +180,7 @@ class MyController < ApplicationController
# Manage user's password
def password
+ @act='password'
@user = User.current
unless @user.change_password_allowed?
flash.now[:error] = l(:notice_can_t_change_password)
@@ -178,12 +200,14 @@ class MyController < ApplicationController
flash.now[:error] = l(:notice_account_wrong_password)
end
end
+ render :template => 'my/account',:layout=>'base_users_new'
rescue Exception => e
if e.message == 'wrong password'
flash.now[:error] = l(:notice_account_wrong_password)
else
flash.now[:error] = e.message
end
+ render :template => 'my/account',:layout=>'base_users_new'
end
# Create a new feeds key
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 23053a48e..b02ebd7e5 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -39,13 +39,15 @@ class UsersController < ApplicationController
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
- :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index]
+ :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
+ :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show]
#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_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
- :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index]
+ :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
+ :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@@ -76,6 +78,8 @@ class UsersController < ApplicationController
# fq
helper :words
+ helper :project_score
+ include UsersHelper
def refresh_changests
if !(@user.nil?) && !(@user.memberships.nil?)
@@ -104,27 +108,41 @@ class UsersController < ApplicationController
#added by young
def user_projects
-
- if User.current.admin?
- @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
- else
- cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
- @memberships = @user.memberships.all(:conditions => cond)
- end
- #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
- #@events_by_day = events.group_by(&:event_date)
- @state = 0
- #add by huang
+
+ #add by huang
unless User.current.admin?
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
render_404
- return
+ return
end
end
- #end
-
+ #end
+ # if User.current.admin?
+ # @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
+ # else
+ # cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
+ # @memberships = @user.memberships.all(:conditions => cond)
+ # end
+ #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
+ #@events_by_day = events.group_by(&:event_date)
+ # @state = 0
+
+ limit = 10;
+ query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
+ query = query.where("m.user_id = ?",@user.id)
+ if(params[:status] == '1')
+ query = query.where("#{Project.table_name}.user_id = ?",@user.id);
+ elsif(params[:status] == '2')
+ query = query.where("#{Project.table_name}.user_id <> ?",@user.id);
+ end
+ @obj_count = query.count();
+
+ @obj_pages = Paginator.new @obj_count,limit,params['page']
+ @list = query.order("#{Project.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
+ @params = params
+
respond_to do |format|
- format.html
+ format.html{render :layout=>'base_users_new'}
format.api
end
end
@@ -237,44 +255,59 @@ class UsersController < ApplicationController
include CoursesHelper
- def user_courses
+ def user_courses
unless User.current.admin?
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
render_404
- return
+ return
end
end
-
+
#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
- if User.current == @user || User.current.admin?
- membership = @user.coursememberships.all
- else
- membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
+ limit = 10;
+ query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
+ query = query.where("m.user_id = ?",@user.id)
+ if(params[:status] == '1')
+ query = query.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now);
+ elsif(params[:status] == '2')
+ query = query.where("endup_time < ?",Time.now);
end
+ @obj_count = query.count();
- membership.sort! {|older, newer| newer.created_on <=> older.created_on }
- @memberships = []
- membership.collect { |e|
- @memberships.push(e)
- }
- ## 判断课程是否过期 [需封装]
- @memberships_doing = []
- @memberships_done = []
- #now_time = Time.now.year
- @memberships.map { |e|
- #end_time = e.course.get_time.year
- isDone = course_endTime_timeout?(e.course)
- if isDone
- @memberships_done.push e
- else
- @memberships_doing.push e
- end
- }
+ @obj_pages = Paginator.new @obj_count,limit,params['page']
+ @list = query.order("#{Course.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
+ @params = params
+ render :layout=>'base_users_new'
+
+ # if User.current == @user || User.current.admin?
+ # membership = @user.coursememberships.all
+ # else
+ # membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
+ # end
+ #
+ # membership.sort! {|older, newer| newer.created_on <=> older.created_on }
+ # @memberships = []
+ # membership.collect { |e|
+ # @memberships.push(e)
+ # }
+ # ## 判断课程是否过期 [需封装]
+ # @memberships_doing = []
+ # @memberships_done = []
+ # #now_time = Time.now.year
+ # @memberships.map { |e|
+ # #end_time = e.course.get_time.year
+ # isDone = course_endTime_timeout?(e.course)
+ # if isDone
+ # @memberships_done.push e
+ # else
+ # @memberships_doing.push e
+ # end
+ # }
# respond_to do |format|
- # format.html
- # format.api
+ # format.html
+ # format.api
# end
end
@@ -408,8 +441,149 @@ class UsersController < ApplicationController
format.api
end
end
-
+
+ def user_courses4show
+ query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
+ query = query.where("m.user_id = ?",@user.id)
+ if User.current == @user #看自己
+ else
+ if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师
+ query = query.joins("join member_roles r on m.id = r.member_id")
+ query = query.where("r.role_id in(7,9)")
+ end
+ query = query.where(Course.table_name+".is_public = 1")
+ # TODO or exists (select 1 from courses c2,members m2 where c2.id=m2.course_id and c2.id=#{Course.table_name}.id and m2.user_id= User.current.id)
+ end
+
+ if params[:lastid]!=nil && !params[:lastid].empty?
+ query = query.where("#{Course.table_name}.id < ?",params[:lastid])
+ end
+ @list = query.order("#{Course.table_name}.id desc").limit(8).all
+
+ render :layout=>nil
+ end
+ def user_projects4show
+
+ query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
+ query = query.where("m.user_id = ?",@user.id)
+ if User.current == @user #看自己
+ else
+ query = query.where(Project.table_name+".is_public = 1")
+ # TODO or exists (select 1 from project c2,members m2 where c2.id=m2.course_id and c2.id=#{Project.table_name}.id and m2.user_id= User.current.id)
+ end
+
+ if params[:lastid]!=nil && !params[:lastid].empty?
+ query = query.where("#{Project.table_name}.id < ?",params[:lastid])
+ end
+ @list = query.order("#{Project.table_name}.id desc").limit(8).all
+
+ render :layout=>nil
+ end
+
+ def user_course_activities
+ @list = []
+ lastid = nil
+ if params[:lastid]!=nil && !params[:lastid].empty?
+ lastid = params[:lastid];
+ end
+
+ user_ids = []
+ if @user == User.current
+ watcher = User.watched_by(@user)
+ watcher.push(User.current)
+ user_ids = watcher.map{|x| x.id}
+ else
+ user_ids << @user.id
+ end
+
+ query_rec_count = 8
+ query_times = 10 #query_times次没查到query_rec_count条记录就不查了
+ query_i = 0;
+ while( true )
+ query_i = query_i+1
+ if(query_i>query_times)
+ break
+ end
+ query = Activity.where(user_id: user_ids)
+ if(lastid != nil)
+ query = query.where("id < ?",lastid)
+ end
+ lastid,item_list = query_activities(query,'course');
+ for item in item_list
+ @list << item
+ if @list.count() >= query_rec_count
+ break
+ end
+ end
+ if @list.count() >= query_rec_count
+ break
+ end
+ if lastid == nil
+ break
+ end
+ end
+ render :layout=>nil
+ end
+
+ def user_project_activities
+ @list = []
+ lastid = nil
+ if params[:lastid]!=nil && !params[:lastid].empty?
+ lastid = params[:lastid];
+ end
+
+ user_ids = []
+ if @user == User.current
+ watcher = User.watched_by(@user)
+ watcher.push(User.current)
+ user_ids = watcher.map{|x| x.id}
+ else
+ user_ids << @user.id
+ end
+
+ query_rec_count = 8
+ query_times = 10 #query_times次没查到query_rec_count条记录就不查了
+ query_i = 0;
+ while( true )
+ query_i = query_i+1
+ if(query_i>query_times)
+ break
+ end
+ query = Activity.where(user_id: user_ids)
+ if(lastid != nil)
+ query = query.where("id < ?",lastid)
+ end
+ lastid,item_list = query_activities(query,'project');
+ for item in item_list
+ @list << item
+ if @list.count() >= query_rec_count
+ break
+ end
+ end
+ if @list.count() >= query_rec_count
+ break
+ end
+ if lastid == nil
+ break
+ end
+ end
+ render :action=>'user_course_activities',:layout=>nil
+ end
+
+ def user_feedback4show
+ query = @user.journals_for_messages
+ if params[:lastid]!=nil && !params[:lastid].empty?
+ query = query.where("#{JournalsForMessage.table_name}.id < ?",params[:lastid])
+ end
+ @list = query.order("#{JournalsForMessage.table_name}.id desc").limit(3).all
+ render :layout=>nil
+ end
+
def show
+ render :layout=>'base_users_new'
+ end
+
+ def show_old
pre_count = 10 #limit
# Time 2015-02-04 11:46:34
# Author lizanle
@@ -830,11 +1004,24 @@ class UsersController < ApplicationController
end
end
###add by huang
- def user_watchlist
+ def user_watchlist
+ limit = 10;
+ query = User.watched_by(@user.id);
+ @obj_count = query.count();
+ @obj_pages = Paginator.new @obj_count,limit,params['page']
+ @list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
+
+ render :template=>'users/user_fanslist',:layout=>'base_users_new'
end
###add by huang
- def user_fanslist
-
+ def user_fanslist
+ limit = 10;
+ query = @user.watcher_users;
+ @obj_count = query.count();
+ @obj_pages = Paginator.new @obj_count,limit,params['page']
+ @list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
+ @action = 'fans'
+ render :layout=>'base_users_new'
end
#william
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb
index f6d01a03d..3727a974e 100644
--- a/app/controllers/watchers_controller.rb
+++ b/app/controllers/watchers_controller.rb
@@ -16,12 +16,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WatchersController < ApplicationController
before_filter :require_login#, :find_watchables, :only => [:watch, :unwatch]
+
+ helper :users
+
def watch
s = WatchesService.new
watchables = s.watch params.merge(:current_user_id => User.current.id)
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
- format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables} }
+ format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add'} }
end
rescue Exception => e
if e.message == "404"
@@ -37,7 +40,7 @@ class WatchersController < ApplicationController
watchables = s.unwatch params.merge(:current_user_id => User.current.id)
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
- format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables} }
+ format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add'} }
end
rescue Exception => e
if e.message == "404"
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index af2d5abc4..8a373edab 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -303,4 +303,159 @@ module UsersHelper
end
end
end
+
+ def get_watcher_users(obj)
+ count = User.watched_by(obj.id).count
+ if count == 0
+ return [0,[]]
+ end
+ list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all
+ return [count,list];
+ end
+
+ def get_fans_users(obj)
+ count = obj.watcher_users.count
+ if count == 0
+ return [0,[]]
+ end
+ list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
+ return [count,list];
+ end
+
+ def query_activities(query,type)
+ query_rec_count = 50
+ #query = query.where("act_type not in ('Contest','Contestnotifications','Principal')")
+ query = query.where("act_type='JournalsForMessage'")
+ #query = query.where("act_type not in (?)", ['JournalsForMessage','Message','HomeworkCommon','News','Issue','Journal','Poll'])
+ list = query.order("id desc").limit(query_rec_count).all
+ if( list == nil || list.count() < query_rec_count )
+ lastid = nil
+ else
+ lastid = list.last.id
+ end
+
+ result = [];
+ for item in list
+ container = get_activity_container(item,type)
+ if( activity_is_show(item,container) )
+ result << { :item=>item,:e=>container }
+ end
+ end
+ return [lastid,result]
+ end
+ def get_activity_container activity,type
+ e = nil;
+ if type == 'project'
+ if activity.act_type == 'Poll'
+ # 项目没有问卷
+ # e = Project.find_by_id(activity.act.polls_group_id)
+ else
+ e = activity.act.project if activity.act.respond_to?('project')
+ end
+ end
+ if type == 'course'
+ if activity.act_type == 'Poll'
+ e = Course.find_by_id(activity.act.polls_group_id)
+ else
+ e = activity.act.course if activity.act.respond_to?('course')
+ end
+ end
+
+ return e;
+ end
+ def activity_is_show(activity,e)
+ if(!e)
+ return false
+ end
+
+ if activity.user_id == User.current.id
+ return true
+ end
+ if( e.visible? )
+ return true
+ end
+ return false
+ end
+ def get_activity_act_showname(activity)
+ case activity.act_type
+ when "HomeworkCommon"
+ return activity.act.name
+ when "Issue"
+ return activity.act.subject
+ when "Journal"
+ return activity.act.notes
+ when "JournalsForMessage"
+ return activity.act.notes
+ when "Message"
+ return activity.act.subject
+ when "News"
+ return activity.act.title
+ when "Poll"
+ return activity.act.polls_name
+ when "Contest"
+ return ''
+ when "Contestnotification"
+ return ''
+ when "Principal"
+ return ''
+ else
+ return activity.act_type
+ end
+ end
+ def get_activity_act_createtime(activity)
+ case activity.act_type
+ when "HomeworkCommon"
+ return activity.act.created_at
+ when "Poll"
+ return activity.act.created_at
+ else
+ return activity.act.created_on
+ end
+ end
+ def get_activity_url(activity,e)
+ case activity.act_type
+ # when "Contest"
+ # when "Contestnotification"
+ # when "Principal"
+ when "HomeworkCommon"
+ return homework_common_index_path( :course=>e.id )
+ when "Issue"
+ return issue_path(activity.act.id)
+ when "Journal"
+ return issue_path( activity.act.journalized_id )
+ when "JournalsForMessage"
+ return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e)
+ when "Message"
+ return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e)
+ when "News"
+ return news_path(activity.act)
+ #return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e)
+ when "Poll"
+ return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s )
+ else
+ return 'javascript:;'
+ end
+ end
+ def get_activity_opt(activity,e)
+ case activity.act_type
+ when "HomeworkCommon"
+ return '创建了作业'
+ when "News"
+ return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻'
+ when "Issue"
+ return '发表了问题'
+ when "Journal"
+ return '回复了问题'
+ when "JournalsForMessage"
+ return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈'
+ #return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : ''
+ when "Message"
+ return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子'
+ when "Poll"
+ return '发布了问卷'
+ else
+ return '有了新动态'
+ end
+ end
+
end
diff --git a/app/views/avatar/upload.js.erb b/app/views/avatar/upload.js.erb
index 1fa90c5a3..41cf3ab77 100644
--- a/app/views/avatar/upload.js.erb
+++ b/app/views/avatar/upload.js.erb
@@ -1,4 +1,8 @@
+<% if @source_type=='User' %>
+var imgSpan = $("img[nhname='avatar_image']");
+imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
+<% else %>
var imgSpan = jQuery('#avatar_image');
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
-
+<% end %>
\ No newline at end of file
diff --git a/app/views/courses/finishcourse.js.erb b/app/views/courses/finishcourse.js.erb
index 2399062fd..0ca89aa19 100644
--- a/app/views/courses/finishcourse.js.erb
+++ b/app/views/courses/finishcourse.js.erb
@@ -1,8 +1,8 @@
<% if @save_flag %>
- $('#finish_course_<%=@course.id%>').replaceWith("<%= escape_javascript(set_course_time(@course_prefs))%>");
+$('#finish_course_<%=@course.id%>').replaceWith("<%= escape_javascript(set_course_time(@course_prefs))%>");
+var html = "<%= escape_javascript( render( :partial => 'users/course_form', :locals => {:item => @course_prefs} ) )%>";
+$('#nh_course_<%=@course.id%>').replaceWith(html);
// alert("关闭成功");
<% else %>
- alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
-<% end %>
-
-
+alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
+<% end %>
\ No newline at end of file
diff --git a/app/views/layouts/_base_footer_new.html.erb b/app/views/layouts/_base_footer_new.html.erb
new file mode 100644
index 000000000..b4856d2af
--- /dev/null
+++ b/app/views/layouts/_base_footer_new.html.erb
@@ -0,0 +1,13 @@
+
+
+
<%= @organizer.description.html_safe %>
+
+
+
+ <% @companies && @companies.each do |company| %>
+
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/layouts/_base_header_new.html.erb b/app/views/layouts/_base_header_new.html.erb
new file mode 100644
index 000000000..63e221cca
--- /dev/null
+++ b/app/views/layouts/_base_header_new.html.erb
@@ -0,0 +1,76 @@
+
\ No newline at end of file
diff --git a/app/views/users/_user_fans_item.html.erb b/app/views/users/_user_fans_item.html.erb
new file mode 100644
index 000000000..66181d23b
--- /dev/null
+++ b/app/views/users/_user_fans_item.html.erb
@@ -0,0 +1,50 @@
+
<% end %>
-
-<% html_title(l(:label_activity)) -%>
+
\ No newline at end of file
diff --git a/app/views/users/user_course_activities.html.erb b/app/views/users/user_course_activities.html.erb
new file mode 100644
index 000000000..8a9996c41
--- /dev/null
+++ b/app/views/users/user_course_activities.html.erb
@@ -0,0 +1,12 @@
+<% for rec in @list %>
+
\ No newline at end of file
diff --git a/app/views/users/user_courses4show.html.erb b/app/views/users/user_courses4show.html.erb
new file mode 100644
index 000000000..a95c90f18
--- /dev/null
+++ b/app/views/users/user_courses4show.html.erb
@@ -0,0 +1,14 @@
+<% for item in @list %>
+
+
<%= h membership.roles.sort.collect(&:to_s).join(', ') %>
-
-
-
-
-
-
-
- <% end %>
-
-<% else %>
-<% if @user != User.current %>
-
<%= l(:label_project_un) %>
-<% else %>
-
<%= l(:label_project_unadd) %>
-<% end %>
-
-<% end %>
-<%= call_hook :view_account_left_bottom, :user => @user %>
-
-
-<% html_title(l(:label_user_project)) -%>
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/app/views/users/user_projects4show.html.erb b/app/views/users/user_projects4show.html.erb
new file mode 100644
index 000000000..d68089741
--- /dev/null
+++ b/app/views/users/user_projects4show.html.erb
@@ -0,0 +1,14 @@
+<% for item in @list %>
+
-
-
\ No newline at end of file
+
+
diff --git a/app/views/users/user_feedback4show.html.erb b/app/views/users/user_feedback4show.html.erb
index d57d4ca5a..9b1c502c8 100644
--- a/app/views/users/user_feedback4show.html.erb
+++ b/app/views/users/user_feedback4show.html.erb
@@ -1,4 +1,4 @@
-<% for item in @list %>
+<% for item in feed_list %>
\ No newline at end of file
diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb
index c46f7dc79..24e6a1b37 100644
--- a/app/views/student_work/_student_work_title.html.erb
+++ b/app/views/student_work/_student_work_title.html.erb
@@ -2,36 +2,36 @@
学号