diff --git a/.gitignore b/.gitignore
index 52cf51417..a88fb8be7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,6 @@ test/*
tmp/*
/app/models/tag.rb
/app/models/tag.rb
+/public/images/requirements/reference - 副本 - 副本.jpg
+
+/public/images/requirements/*.jpg
diff --git a/app/assets/javascripts/teachers.js b/app/assets/javascripts/teachers.js
new file mode 100644
index 000000000..dee720fac
--- /dev/null
+++ b/app/assets/javascripts/teachers.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
diff --git a/app/assets/stylesheets/teachers.css b/app/assets/stylesheets/teachers.css
new file mode 100644
index 000000000..afad32db0
--- /dev/null
+++ b/app/assets/stylesheets/teachers.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index fa4de26f9..b865328f5 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -88,10 +88,12 @@ class AccountController < ApplicationController
# create a new token for password recovery
token = Token.new(:user => user, :action => "recovery")
if token.save
- Mailer.lost_password(token).deliver
- flash[:notice] = l(:notice_account_lost_email_sent)
- redirect_to signin_path
- return
+ Thread.new do
+ Mailer.lost_password(token).deliver
+ end
+ flash[:notice] = l(:notice_account_lost_email_sent)
+ redirect_to signin_path
+ return
end
end
end
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 4d6ed2966..ebf3c3ba5 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -115,13 +115,30 @@ class AttachmentsController < ApplicationController
format.js
end
end
+
+ def delete_homework
+ @bid = @attachment.container.bid
+ # Make sure association callbacks are called
+ container = @attachment.container
+ @attachment.container.attachments.delete(@attachment)
+ if container.attachments.empty?
+ container.delete
+ end
+
+ respond_to do |format|
+ format.html { redirect_to_referer_or respond_path(@bid) }
+ format.js
+ end
+ end
private
def find_project
@attachment = Attachment.find(params[:id])
# Show 404 if the filename in the url is wrong
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
- @project = @attachment.project
+ unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach'
+ @project = @attachment.project
+ end
rescue ActiveRecord::RecordNotFound
render_404
end
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 6e8484809..f41209d8c 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -3,11 +3,16 @@ class BidsController < ApplicationController
#Added by young
menu_item :respond
menu_item :project, :only => [:show_project,:show_results]
+ menu_item :homework_respond, :only => :homework_respond
+ menu_item :homework_statistics, :only => :homework_statistics
#Ended by young
before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results]
before_filter :require_login,:only => [:set_reward]
helper :watchers
+ helper :attachments
+ include AttachmentsHelper
+
def index
# Modified by nie
# @requirement_title = "4"
@@ -69,11 +74,17 @@ class BidsController < ApplicationController
@state = false
respond_to do |format|
+ if @bid.reward_type == 3
format.html {
+ render :layout => 'base_homework'
+ }
+ else
+ format.html {
render :layout => 'base_bids'
}
+ end
format.api
-
+
end
end
@@ -88,14 +99,51 @@ class BidsController < ApplicationController
# @project = Project.where("id in []", a)
@user = @bid.author
@bidding_project = @bid.biding_projects
+ if @bid.homework_type == 1
+ @homework = HomeworkAttach.new
+ @homework_list = @bid.homeworks
+ end
respond_to do |format|
+ if @bid.reward_type == 3
format.html {
+ render :layout => 'base_homework'
+ }
+ else
+ format.html {
render :layout => 'base_bids'
}
+ end
format.api
end
end
+
+ ##### by huang
+ def show_project_homework
+ # flash[:notice] = ""
+ @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
+ @option = []
+ @membership.each do |membership|
+ @option << membership.project
+ end
+ # a = [1]
+ # @project = Project.where("id in []", a)
+ @user = @bid.author
+ @bidding_project = @bid.biding_projects
+ respond_to do |format|
+ if @bid.reward_type == 3
+ format.html {
+ render :layout => 'base_homework'
+ }
+ else
+ format.html {
+ render :layout => 'base_bids'
+ }
+ end
+ format.api
+ end
+ end
+
###添加应标项目
def add
project = Project.where('name = ?', params[:bid]).first
@@ -105,7 +153,11 @@ class BidsController < ApplicationController
flash[:notice] = l(:label_bidding_succeed)
end
else
+ if @bid.reward_type == 3
+ flash[:error] = l(:label_bidding_homework_fail)
+ else
flash[:error] = l(:label_bidding_fail)
+ end
end
@bidding_project = @bid.biding_projects
respond_to do |format|
@@ -219,6 +271,70 @@ class BidsController < ApplicationController
render :action => 'new_bid'
end
end
+
+ def create_homework
+ @bid = Bid.new
+ @bid.name = params[:bid][:name]
+ @bid.description = params[:bid][:description]
+ @bid.reward_type = 3
+ # @bid.budget = params[:bid][:budget]
+ @bid.deadline = params[:bid][:deadline]
+ @bid.budget = 0
+ @bid.author_id = User.current.id
+ @bid.commit = 0
+ @bid.homework_type = params[:bid][:homework_type]
+ @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
+ # @bid.
+ if @bid.save
+ HomeworkForCourse.create(:project_id => params[:course_id], :bid_id => @bid.id)
+ unless @bid.watched_by?(User.current)
+ if @bid.add_watcher(User.current)
+ flash[:notice] = l(:label_bid_succeed)
+ end
+ end
+ redirect_to respond_path(@bid)
+ else
+ @bid.safe_attributes = params[:bid]
+ render :action => 'new_bid'
+ end
+ end
+
+ def add_homework
+ # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
+ # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
+ @homework = HomeworkAttach.new
+ @homework.bid_id = @bid.id
+ @homework.user_id = User.current.id
+ @homework.save_attachments(params[:attachments])
+ @homework.save
+ @homework_list = @bid.homeworks
+
+ end
+
+ # 作业统计
+ def homework_statistics
+ @course = @bid.courses.first
+ @member = []
+ @course.memberships.each do |member|
+ unless (member.roles && Role.where('id = ? ', 3)).empty?
+ @member.push member
+ end
+ end
+ if @bid.homework_type = 1
+ @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id)
+ @homework_type = true
+ else
+
+ @homework_type = false
+ end
+ @user = @bid.author
+ render :layout => 'base_homework'
+ end
+
+ def homework_respond
+ @user = @bid.author
+ render :layout => 'base_homework'
+ end
def more
@jour = @bid.journals_for_messages
@@ -231,6 +347,7 @@ class BidsController < ApplicationController
#format.api { render_api_ok }
end
end
+
def back
@jour = @bid.journals_for_messages
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index 999544e7b..81192c597 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -19,8 +19,9 @@ class BoardsController < ApplicationController
layout 'base_projects'#by young
default_search_scope :messages
before_filter :find_project_by_project_id, :find_board_if_available
- before_filter :authorize, :except => [:new, :show, :create]
+ before_filter :authorize, :except => [:new, :show, :create, :index]
accept_rss_auth :index, :show
+
helper :sort
include SortHelper
@@ -33,6 +34,11 @@ class BoardsController < ApplicationController
@board = @boards.first
show
end
+ if @project.project_type == 1
+ render :layout => 'base_courses'
+ else
+ render :layout => false if request.xhr?
+ end
end
def show
@@ -54,7 +60,11 @@ class BoardsController < ApplicationController
preload(:author, {:last_reply => :author}).
all
@message = Message.new(:board => @board)
- render :action => 'show', :layout => !request.xhr?
+ if @project.project_type
+ render :action => 'show', :layout => 'base_courses'
+ else
+ render :action => 'show', :layout => !request.xhr?
+ end
}
format.atom {
@messages = @board.messages.
@@ -70,6 +80,9 @@ class BoardsController < ApplicationController
def new
@board = @project.boards.build
@board.safe_attributes = params[:board]
+ if @project.project_type
+ render :layout => 'base_courses'
+ end
end
def create
@@ -90,6 +103,9 @@ class BoardsController < ApplicationController
end
def update
+ if @project.project_type
+ render :layout => 'base_courses'
+ end
@board.safe_attributes = params[:board]
if @board.save
redirect_to_settings_in_projects
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
new file mode 100644
index 000000000..137079233
--- /dev/null
+++ b/app/controllers/courses_controller.rb
@@ -0,0 +1,42 @@
+class CoursesController < ApplicationController
+
+
+ before_filter :require_login, :only => [:join, :unjoin]
+
+ def join
+ if User.current.logged?
+ course = Project.find(params[:object_id])
+ if params[:course_password].to_i == Course.find_by_extra(course.identifier).state
+ members = []
+ members << Member.new(:role_ids => [5], :user_id => User.current.id)
+ course.members << members
+
+ StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
+ @state = 0
+ else
+ @state = 1
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
+
+ def unjoin
+ if User.current.logged?
+
+ @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id)
+ @member.first.destroy
+
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
+ joined.each do |join|
+ join.delete
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index a311fc765..67c057eef 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -22,7 +22,7 @@ class DocumentsController < ApplicationController
before_filter :find_project_by_project_id, :only => [:index, :new, :create]
before_filter :find_model_object, :except => [:index, :new, :create]
before_filter :find_project_from_association, :except => [:index, :new, :create]
- before_filter :authorize #, :except => [:index]#Added by young
+ before_filter :authorize , :except => [:index]#Added by young
helper :attachments
@@ -40,11 +40,18 @@ class DocumentsController < ApplicationController
@grouped = documents.group_by(&:category)
end
@document = @project.documents.build
- render :layout => false if request.xhr?
+ if @project.project_type == 1
+ render :layout => 'base_courses'
+ else
+ render :layout => false if request.xhr?
+ end
end
def show
@attachments = @document.attachments.all
+ if @project.project_type
+ render :action => 'show', :layout => 'base_courses'
+ end
end
def new
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index cb4c1b8ff..1048c12bd 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -34,11 +34,20 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse
- render :layout => !request.xhr?
+
+ if @project.project_type == 1
+ render :layout => 'base_courses'
+ else
+ render :layout => !request.xhr?
+ end
end
def new
@versions = @project.versions.sort
+ @course_tag = @project.project_type
+ if @course_tag
+ render :layout => 'base_courses'
+ end
end
def create
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 27d195f0d..56422dcd6 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -49,7 +49,11 @@ class MessagesController < ApplicationController
all
@reply = Message.new(:subject => "RE: #{@message.subject}")
- render :action => "show", :layout => "base_projects"#by young
+ if @message.board.project.project_type
+ render :action => "show", :layout => "base_courses"#by young
+ else
+ render :action => "show", :layout => "base_projects"#by young
+ end
end
# Create a new topic
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 48c6a7d59..21a474e89 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -77,7 +77,7 @@ class MyController < ApplicationController
# ue.save
# end
- # added by bai 往数据库里写职业、性别和地区
+ # added by bai
if @user.user_extensions.nil?
se = UserExtensions.new
se.user_id = @user.id
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 91da55dda..bf02dabce 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -46,12 +46,18 @@ class NewsController < ApplicationController
@newss = scope.all(:include => [:author, :project],
:order => "#{News.table_name}.created_on DESC",
:offset => @offset,
- :limit => @limit)
-
+ :limit => @limit)
+
respond_to do |format|
format.html {
@news = News.new # for adding news inline
+ # huang
+
+ if @project.project_type == 1
+ render :layout => 'base_courses'
+ else
render :layout => false if request.xhr?
+ end
}
format.api
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
@@ -61,10 +67,18 @@ class NewsController < ApplicationController
def show
@comments = @news.comments
@comments.reverse! if User.current.wants_comments_in_reverse_order?
+ @course_tag = @project.project_type
+ if @course_tag
+ render :layout => 'base_courses'
+ end
end
def new
@news = News.new(:project => @project, :author => User.current)
+ @course_tag = @project.project_type
+ if @course_tag
+ render :layout => 'base_courses'
+ end
end
def create
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 926b6a648..67c0edb23 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -15,20 +15,40 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectsController < ApplicationController
+ # if @project.project_type == 1
layout 'base_projects'# by young
menu_item :overview
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
+
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
-
- before_filter :find_project, :except => [ :index, :search, :list, :new, :create, :copy ]
- before_filter :authorize, :except => [:watcherlist, :index, :search, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback, :project_respond]
+
+ menu_item l(:label_homework), :only => :homework
+ menu_item l(:label_course_file), :only => :index
+ menu_item l(:label_course_news), :only => :index
+ # end
+
+
+ # layout 'base_courses'# by young
+ # menu_item :overview
+ # menu_item l(:label_homework), :only => :homework
+ # menu_item :files, :only => :files
+#
+ # layout 'base_courses'
+ # menu_item l(:label_homework), :only => homework
+ # menu_item l(:label_course_file), :only => files
+ # menu_item l(:label_settings), :only => settings
+
+ before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join]
+ before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
before_filter :authorize_global, :only => [:new, :create]
- before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
+ before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
#by young
- before_filter :member, :file, :statistics, :watcherlist
+ # before_filter :member, :file, :statistics, :watcherlist
+ # modified by fq
+ before_filter :file, :statistics, :watcherlist
#
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
@@ -39,6 +59,8 @@ class ProjectsController < ApplicationController
end
end
+ helper :bids
+ include BidsHelper
helper :sort
include SortHelper
helper :custom_fields
@@ -222,6 +244,43 @@ class ProjectsController < ApplicationController
end
end
+ # added by fq
+ def new_join
+ @course = Project.find(params[:object_id])
+ end
+
+ #Added by young
+ def homework
+ @offset, @limit = api_offset_and_limit({:limit => 10})
+ @bids = @project.homeworks
+ @bids = @bids.like(params[:name]) if params[:name].present?
+ @bid_count = @bids.count
+ @bid_pages = Paginator.new @bid_count, @limit, params['page']
+
+ @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
+
+ def new_homework
+ if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))
+ @homework = Bid.new
+ @homework.safe_attributes = params[:bid]
+ render :layout => 'base_courses'
+ else
+ render_404
+ end
+
+ end
+ #Ended by young
+
def feedback
@jours = @project.journals_for_messages.reverse
@limit = 10
@@ -269,18 +328,36 @@ class ProjectsController < ApplicationController
end
def new
+ @course_tag = params[:course]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
+ ##add by huang
+ @course=Course.new
+ @course.safe_attributes = params[:course]
+ ##end
render :layout => 'base'
end
def create
+ @course_tag = params[:project][:project_type]
+ if(@course_tag=="1")
+ @course = Course.new
+ @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
+ @course.safe_attributes = params[:project][:course]
+ @course.tea_id = User.current.id
+ @course.save
+ # project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id)
+ # project_status = ProjectStatus.create(:project_id => @project.id)
+ end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
+ if @course_tag == '1'
+ @project.identifier = @course.extra
+ end
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
@@ -289,7 +366,7 @@ class ProjectsController < ApplicationController
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
- if params[:project][:is_public] == 1
+ if params[:project][:is_public] == '1' || @course_tag=="1"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0)
end
@project.members << m
@@ -300,7 +377,12 @@ class ProjectsController < ApplicationController
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
- redirect_to new_project_path(attrs)
+ redirect_to new_project_path(attrs, :course => '0')
+ #Added by young
+
+ elsif params[:course_continue]
+ redirect_to new_project_path(:course => '1')
+ #Ended by young
else
redirect_to settings_project_path(@project)
end
@@ -358,7 +440,6 @@ class ProjectsController < ApplicationController
@user = User.find_by_id(ProjectInfo.find_by_project_id(@project.id).user_id)
cond = @project.project_condition(Setting.display_subprojects_issues?)
-
@open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker)
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
@@ -378,7 +459,9 @@ class ProjectsController < ApplicationController
"show_issues" => true,
"show_files" => true,
"show_documents" => true,
- "show_messages" => true
+ "show_messages" => true,
+ "show_news" => true,
+ "show_bids" => true
}
@date_to ||= Date.today + 1
@date_from = @date_to - @days
@@ -415,8 +498,9 @@ class ProjectsController < ApplicationController
end
@document = @project.documents.build
#
+ @base_courses_tag = @project.project_type
respond_to do |format|
- format.html
+ format.html{render :layout => 'base_courses' if @base_courses_tag==1}
format.api
end
end
@@ -427,6 +511,16 @@ class ProjectsController < ApplicationController
@member ||= @project.members.new
@trackers = Tracker.sorted.all
@wiki ||= @project.wiki
+ #Added by young
+ # @course_tag = params[:course]
+ # if @course_tag == '1'
+ if @project.project_type == 1
+ @course = Course.find_by_extra(@project.identifier)
+ render :layout => 'base_courses'
+ else
+ render :layout => 'base_projects'
+ end
+ #Ended by young
end
def edit
@@ -434,9 +528,27 @@ class ProjectsController < ApplicationController
#by young
def member
+ if @project.project_type == 1
+ render :layout => 'base_courses'
+ end
end
+
+ # def news
+ # if @project.project_type == 1
+ # render :layout => 'base_courses'
+ # end
+ # end
def file
+ # if @project.project_type == 1
+ # render :layout => 'base_courses'
+ # end
+ # @course_tag = params[:course]
+ # if @course_tag == '1'
+ # render :layout => 'base_courses'
+ # end
+
+ # User.current
end
def statistics
@@ -447,6 +559,10 @@ class ProjectsController < ApplicationController
def update
@project.safe_attributes = params[:project]
if validate_parent_id && @project.save
+ @course = Course.find_by_extra(@project.identifier)
+ @course.state = params[:project][:course][:state]
+ @course.term = params[:project][:course][:term]
+ @course.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
if params[:project][:is_public] == '0'
@@ -459,7 +575,7 @@ class ProjectsController < ApplicationController
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
- redirect_to settings_project_path(@project)
+ redirect_to settings_project_path(@project,:course => @project.project_type)
}
format.api { render_api_ok }
end
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 94de4bfbb..61a3bfb51 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -43,15 +43,26 @@ class RepositoriesController < ApplicationController
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
@repository.project = @project
- render :layout => 'base_projects'
+ @course_tag = params[:course]
+ if @course_tag == 1
+ render :layout => 'base_courses'
+ else
+ render :layout => 'base_projects'
+ end
end
+
def newrepo
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
@repository.project = @project
- render :layout => 'base_projects'
+ @course_tag = params[:course]
+ if @course_tag == 1
+ render :layout => 'base_courses'
+ else
+ render :layout => 'base_projects'
+ end
end
def fork
@@ -209,7 +220,12 @@ class RepositoriesController < ApplicationController
@changesets = @repository.latest_changesets(@path, @rev)
@properties = @repository.properties(@path, @rev)
@repositories = @project.repositories
- render :action => 'show', :layout => 'base_projects'
+ @course_tag = params[:course]
+ if @course_tag == 1
+ render :action => 'show', :layout => 'base_courses'
+ else
+ render :action => 'show', :layout => 'base_projects'
+ end
end
end
@@ -369,6 +385,8 @@ class RepositoriesController < ApplicationController
end
def stats
+ @project_id = params[:id]
+ @repository_id = @repository.identifier
render :layout => 'base_projects'
end
diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb
new file mode 100644
index 000000000..b4d0c4839
--- /dev/null
+++ b/app/controllers/teachers_controller.rb
@@ -0,0 +1,5 @@
+class TeachersController < ApplicationController
+ def show
+
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index fa8879921..825c79060 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -17,21 +17,23 @@
class UsersController < ApplicationController
layout 'base_users'
#Added by young
- menu_item :activity
+ menu_item :activity
menu_item :user_information, :only => :info
menu_item :user_project, :only => :user_projects
menu_item :requirement_focus, :only => :watch_bids
menu_item :user_newfeedback, :only => :user_newfeedback
+ menu_item :user_course, :only => :user_courses
#Ended by young
- before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update]
- before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership,
+ before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:update, :user_courses]
+ #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,
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
#william
- before_filter :require_login,:only => :tag_save
+ before_filter :require_login, :only => :tag_save
helper :sort
@@ -117,6 +119,68 @@ class UsersController < ApplicationController
end
end
# end
+
+ # added by fq
+ def user_courses
+ case params[:type]
+ when "2"
+ @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
+
+ @memberships = []
+ @membership.each do |membership|
+ if membership.project.project_type == 1
+ @membership << membership
+ end
+ end
+ @state = 2
+
+ when "1"
+ @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
+
+ @memberships = []
+ @membership.each do |membership|
+ if membership.project.project_type == 1
+ @memberships << membership
+ end
+ end
+ @bid = []
+ @memberships.each do |membership|
+ @bid += membership.project.homeworks
+ end
+ @bid = @bid.group_by {|bid| bid.courses.first.id}
+ @state = 1
+
+ else
+ @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
+ @memberships = []
+ @membership.each do |membership|
+ if membership.project.project_type == 1
+ @memberships << membership
+ end
+ end
+ @state = 0
+ end
+
+ # events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
+ # @events_by_day = events.group_by(&:event_date)
+
+ # @state = 0
+
+ #add by huang
+ unless User.current.admin?
+ if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
+ render_404
+ return
+ end
+ end
+ #end
+
+ # respond_to do |format|
+ # format.html
+ # format.api
+ # end
+ end
+ # end
# modified by fq
def user_newfeedback
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb
index 29901aa6b..b06b8cbb3 100644
--- a/app/controllers/watchers_controller.rb
+++ b/app/controllers/watchers_controller.rb
@@ -23,6 +23,41 @@ class WatchersController < ApplicationController
def unwatch
set_watcher(@watchables, User.current, false)
end
+
+ def join
+ if User.current.logged?
+ course = Project.find(params[:object_id])
+ if params[:course_password] == '123'
+ members = []
+ members << Member.new(:role_ids => [5], :user_id => User.current.id)
+ course.members << members
+
+ StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
+ else
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
+
+ def unjoin
+ if User.current.logged?
+
+ @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id)
+ @member.first.destroy
+
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
+ joined.each do |join|
+ join.delete
+ end
+ end
+ respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id])} }
+ end
+ end
before_filter :find_project, :authorize, :only => [:new, :create, :append, :destroy, :autocomplete_for_user]
accept_api_auth :create, :destroy
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5204788cf..54ab7b76b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -31,7 +31,18 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
-
+
+ #Added by young
+ #Define the course menu's link class
+ def link_class(label)
+ if current_menu_item == label
+ @class = 'selected'
+ else
+ @class = ''
+ end
+ return @class
+ end
+ #Ended by young
# Return true if user is authorized for controller/action, otherwise false
def authorize_for(controller, action)
User.current.allowed_to?({:controller => controller, :action => action}, @project)
@@ -966,7 +977,7 @@ module ApplicationHelper
end
def lang_options_for_select(blank=true)
- (blank ? [["(auto)", ""]] : []) + languages_options
+ { 'Chinese简体中文 '=> 'zh', :English => :en}
end
def label_tag_for(name, option_tags = nil, options = {})
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index a4925343f..f61399c85 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -31,6 +31,15 @@ module AttachmentsHelper
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
end
end
+
+ def attach_delete(project)
+ if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
+ true
+ else
+ false
+ end
+
+ end
def render_api_attachment(attachment, api)
api.attachment do
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 0d12a22ea..1b8340721 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -35,6 +35,7 @@ module ProjectsHelper
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
+
end
def sort_project(state)
@@ -60,6 +61,20 @@ module ProjectsHelper
end
+ #Added by young
+ def course_settings_tabs
+ tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'},
+ {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
+ # {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
+ {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}
+ ]
+ tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
+
+ end
+ #Ended by young
+
+
+
def parent_project_select_tag(project)
selected = project.parent
@@ -78,7 +93,13 @@ module ProjectsHelper
# Renders the projects index
def render_project_hierarchy(projects)
render_project_nested_lists(projects) do |project|
- s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
+ #Modified by young
+ if (project.project_type==1)
+ s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")+"(#{l(:label_course)}) ".html_safe
+ else
+ s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
+ end
+ #Ended by young
if project.description.present?
#Delete by nie.
# s << content_tag('td', textilizable(project.short_description, :project => project), :class => 'wiki description')
@@ -111,5 +132,18 @@ module ProjectsHelper
def get_projects_by_tag(tag_name)
Project.tagged_with(tag_name).order('updated_on desc')
end
+
+ # added by fq
+ def homework_type_option
+ type = []
+ option1 = []
+ option2 = []
+ option1 << '作业最终以附件形式提交'
+ option1 << 1
+ option2 << '作业最终以项目形式提交'
+ option2 << 2
+ type << option1
+ type << option2
+ end
end
diff --git a/app/helpers/teachers_helper.rb b/app/helpers/teachers_helper.rb
new file mode 100644
index 000000000..1015c8c9f
--- /dev/null
+++ b/app/helpers/teachers_helper.rb
@@ -0,0 +1,2 @@
+module TeachersHelper
+end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 32c4b6142..c813714d3 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -90,6 +90,26 @@ module UsersHelper
end
content_tag('div', content, :class => "pagination")
end
+
+ def user_course(state)
+ content = ''.html_safe
+ case state
+ when 0
+ s = content_tag('span', '我的课程', :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
+ when 1
+ s = content_tag('span', '我的作业', :class => "current-page")
+ content << content_tag('li', link_to('我的课程', {:controller => 'users', :action => 'user_courses'}))
+ content << content_tag('li', s, :class => "current-page")
+ when 2
+ s = content_tag('span', '课程通知', :class => "current-page")
+ content << content_tag('li', link_to('课程通知', {:controller => 'users', :action => 'user_courses'}))
+ content << content_tag('li', s, :class => "current-page")
+ end
+ content_tag('div', content, :class => "pagination")
+
+ end
# added by huang
def sort_user(state)
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 052c3fd25..2baee6479 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -45,6 +45,21 @@ module WatchersHelper
link_to text, url, :remote => true, :method => method, :class => css
end
+
+ # added by fq
+ def join_in_course(course, user)
+ return '' unless user && user.logged?
+ joined = user.member_of?(course)
+ text = joined ? '退出课程' : '加入课程'
+ url_t = join_path(:object_id => course.id)
+ url_f = try_join_path(:object_id => course.id)
+ method = joined ? 'delete' : 'post'
+ if joined
+ link_to text, url_t, :remote => true, :method => method, :id => 'join', :confirm => l(:text_are_you_sure)
+ else
+ link_to text, url_f, :remote => true, :method => method, :id => 'join'
+ end
+ end
# Returns the css class used to identify watch links for a given +object+
def watcher_css(objects)
diff --git a/app/models/bid.rb b/app/models/bid.rb
index 5821fb0c1..e6b8511c3 100644
--- a/app/models/bid.rb
+++ b/app/models/bid.rb
@@ -1,20 +1,26 @@
####by fq
class Bid < ActiveRecord::Base
- #attr_accessible :author_id, :budget, :deadline, :name, :description
+ attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type
include Redmine::SafeAttributes
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
+ belongs_to :course
has_many :biding_projects, :dependent => :destroy
has_many :projects, :through => :biding_projects
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
+ has_many :homework_for_courses, :dependent => :destroy
+ has_many :courses, :through => :homework_for_courses, :source => :project
+ has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
+
+ acts_as_attachable
NAME_LENGTH_LIMIT = 60
DESCRIPTION_LENGTH_LIMIT = 250
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
- validates_presence_of :author_id, :name, :deadline, :budget
+ validates_presence_of :author_id, :name, :deadline
# validates_presence_of :deadline, :message => 'test'
# validates_format_of :deadline, :with =>
validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
@@ -46,7 +52,7 @@ class Bid < ActiveRecord::Base
:author => :author,
:url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}}
- acts_as_activity_provider :find_options => {:include => [:author]},
+ acts_as_activity_provider :find_options => {:include => [:projects, :author]},
:author_key => :author_id
@@ -54,6 +60,10 @@ class Bid < ActiveRecord::Base
'description',
'budget',
'deadline'
+
+ # safe_attributes 'name',
+ # 'description',
+ # 'deadline'
def add_jour(user, notes, reference_user_id = 0)
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
diff --git a/app/models/course.rb b/app/models/course.rb
new file mode 100644
index 000000000..276cc7652
--- /dev/null
+++ b/app/models/course.rb
@@ -0,0 +1,20 @@
+class Course < ActiveRecord::Base
+ include Redmine::SafeAttributes
+
+ attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term
+ belongs_to :project, :class_name => 'Project', :foreign_key => :extra # 定义一个project方法, 该方法通过extra来调用project表
+ belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
+ has_many :bid
+ validates_presence_of :state, :term
+ safe_attributes 'extra',
+ 'time',
+ 'name',
+ 'extra',
+ 'code',
+ 'location',
+ 'tea_id',
+ 'state',
+ 'term'
+
+
+end
diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb
new file mode 100644
index 000000000..aea68abb5
--- /dev/null
+++ b/app/models/homework_attach.rb
@@ -0,0 +1,9 @@
+class HomeworkAttach < ActiveRecord::Base
+ attr_accessible :bid_id, :user_id
+
+ belongs_to :user
+ belongs_to :bid
+
+ acts_as_attachable
+
+end
diff --git a/app/models/homework_for_course.rb b/app/models/homework_for_course.rb
new file mode 100644
index 000000000..7a440449a
--- /dev/null
+++ b/app/models/homework_for_course.rb
@@ -0,0 +1,8 @@
+class HomeworkForCourse < ActiveRecord::Base
+ attr_accessible :bid_id, :project_id
+
+ belongs_to :bid
+ belongs_to :project
+
+
+end
diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb
new file mode 100644
index 000000000..3bca47791
--- /dev/null
+++ b/app/models/journals_for_message_observer.rb
@@ -0,0 +1,7 @@
+# Added by young
+class JournalsForMessageObserver < ActiveRecord::Observer
+ def after_create(journal_for_message)
+ Mailer.journals_for_message_add(User.current, journal_for_message).deliver
+ end
+end
+
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 1db19f14e..ed942f0d3 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -26,6 +26,15 @@ class Mailer < ActionMailer::Base
def self.default_url_options
{ :host => Setting.host_name, :protocol => Setting.protocol }
end
+
+ # Builds a Mail::Message object used to email recipients of the added journals for message.
+ #
+ # def journals_for_message_add(user, journals_for_message)
+ # @user = User.current
+ # @url = url_for(:controller => 'users', :action => 'user_newfeedback')
+ # mail :to => user.mail,
+ # :subject => "hello"
+ # end
# Builds a Mail::Message object used to email recipients of the added issue.
#
diff --git a/app/models/project.rb b/app/models/project.rb
index bd856f7d0..53e407246 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -53,13 +53,27 @@ class Project < ActiveRecord::Base
has_many :changesets, :through => :repository
# added by fq
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
+ has_many :homework_for_courses, :dependent => :destroy
+ has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
+ has_many :students_for_courses, :dependent => :destroy
+ has_many :student, :through => :students_for_courses, :source => :user
+ # has_one :cour, :class_name => 'Course', :foreign_key => :extra, :dependent => :destroy
+
# end
#ADDED BY NIE
- has_many :project_infos, :dependent => :destroy
+ has_many :project_infos, :dependent => :destroy
+ has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
+ has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
+ has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
#end
+
has_one :wiki, :dependent => :destroy
- # Custom field for the project issues
+ ##added by xianbo
+ has_one :course, :dependent => :destroy ,:order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
+ accepts_nested_attributes_for :course
+ ##end
+ # Custom field for the project issues
has_and_belongs_to_many :issue_custom_fields,
:class_name => 'IssueCustomField',
:order => "#{CustomField.table_name}.position",
@@ -682,7 +696,10 @@ class Project < ActiveRecord::Base
'custom_field_values',
'custom_fields',
'tracker_ids',
- 'issue_custom_field_ids'
+ 'issue_custom_field_ids',
+ 'project_type'
+
+
safe_attributes 'enabled_module_names',
:if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
@@ -1027,6 +1044,10 @@ class Project < ActiveRecord::Base
def update_position_under_parent
set_or_update_position_under(parent)
end
+
+ def course
+ @course
+ end
# Inserts/moves the project so that target's children or root projects stay alphabetically sorted
def set_or_update_position_under(target_parent)
diff --git a/app/models/students_for_course.rb b/app/models/students_for_course.rb
new file mode 100644
index 000000000..597d74da6
--- /dev/null
+++ b/app/models/students_for_course.rb
@@ -0,0 +1,10 @@
+class StudentsForCourse < ActiveRecord::Base
+ attr_accessible :course_id, :student_id
+
+ belongs_to :course, :class_name => 'Project', :foreign_key => :course_id
+ belongs_to :student, :class_name => 'User', :foreign_key => :student_id
+
+ validates_presence_of :course_id, :student_id
+ validates_uniqueness_of :student_id, :scope => :course_id
+
+end
diff --git a/app/models/teacher.rb b/app/models/teacher.rb
new file mode 100644
index 000000000..cf57a1be8
--- /dev/null
+++ b/app/models/teacher.rb
@@ -0,0 +1,13 @@
+class Teacher < ActiveRecord::Base
+ attr_accessible :course_code, :couurse_time, :location, :tea_name
+ include Redmine::SafeAttributes
+
+ belongs_to :project
+
+ safe_attributes'tea_name',
+ 'location',
+ 'couurse_time',
+ 'course_code',
+ 'extra'
+
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 978170017..981ff5af5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -82,8 +82,13 @@ class User < Principal
has_many :bids, :foreign_key => 'author_id', :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
- has_many :journal_replies
- has_many :activities
+ has_many :journal_replies, :dependent => :destroy
+ has_many :activities, :dependent => :destroy
+ has_many :students_for_courses, :dependent => :destroy
+ has_many :courses, :through => :students_for_courses, :source => :project
+ has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
+ has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
+ has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
#####
@@ -150,13 +155,27 @@ class User < Principal
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true)
end
+ ### fq
+ def join_in?(course)
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id)
+ if joined.size > 0
+ true
+ else
+ false
+ end
+ end
+ ## end
+
def count_new_jour
count = self.new_jours.count
end
def set_mail_notification
+ ##add byxianbo
+ thread=Thread.new do
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
true
+ end
end
def update_hashed_password
diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb
index 1c9dd6854..ce666940e 100644
--- a/app/views/account/register.html.erb
+++ b/app/views/account/register.html.erb
@@ -187,48 +187,6 @@
}
-
-
<%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %>
@@ -253,29 +211,14 @@
<%="#{l(:label_mail_attention)} "%>
<%= f.select :language, lang_options_for_select %>
-
+
-
-
+ <%= select_tag 'identity', "#{l(:label_teacher)}
+ #{l(:label_student)}
+ #{l(:label_other)} ".html_safe %>
<%= l(:label_gender) %>
@@ -283,7 +226,7 @@
<%= select_tag 'gender', "#{l(:label_gender_male)}
#{l(:label_gender_female)} ".html_safe %>
-
<%= l(:label_location) %>
+
<%= l(:label_location) %> *
--请选择省份--
@@ -328,11 +271,9 @@
-
<%= submit_tag l(:button_submit) %>
<% end %>
-
<% if Setting.openid? %>
<%= f.text_field :identity_url %>
<% end %>
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb
index d2ab22ced..81eb416af 100644
--- a/app/views/attachments/_links.html.erb
+++ b/app/views/attachments/_links.html.erb
@@ -9,11 +9,19 @@
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
(<%= number_to_human_size attachment.filesize %>)
<% if options[:deletable] %>
+ <% unless attachment.container_type == 'HomeworkAttach' %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
:title => l(:button_delete) %>
+ <% else %>
+ <%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
+ :data => {:confirm => l(:text_are_you_sure)},
+ :method => :delete,
+ :class => 'delete',
+ :title => l(:button_delete) %>
+ <% end %>
<% end %>
<% if options[:author] %>
<%= h(attachment.author) %>, <%= format_time(attachment.created_on) %>
diff --git a/app/views/attachments/delete.js.erb b/app/views/attachments/delete.js.erb
new file mode 100644
index 000000000..3cfb5845f
--- /dev/null
+++ b/app/views/attachments/delete.js.erb
@@ -0,0 +1 @@
+$('#attachments_<%= j params[:attachment_id] %>').remove();
diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb
new file mode 100644
index 000000000..cea2165d4
--- /dev/null
+++ b/app/views/bids/_bid_homework_show.html.erb
@@ -0,0 +1,46 @@
+
+<% bids.each do |bid|%>
+
+
+
+ <%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %>
+
+
+
+ <%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
+
+
+
+
+
+ <% if bid.reward_type.nil? or bid.reward_type == 1 %> <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %>
+ <%= bid.budget%> <% elsif bid.reward_type == 2 %> <%= l(:label_bids_reward_method) %><%= bid.budget%> <% else %>
+
+ <% end %>
+
+
+ <%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %> ) <%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %> )
+
+
+ <%= format_time bid.created_on %>
+
+
+
+
+
+
+ <%= bid.description%>
+
+
+
+
+
+
+
+<% end %>
+
+
diff --git a/app/views/bids/_bid_show.html.erb b/app/views/bids/_bid_show.html.erb
index 40760e12f..d3f1cbb74 100644
--- a/app/views/bids/_bid_show.html.erb
+++ b/app/views/bids/_bid_show.html.erb
@@ -1,100 +1,41 @@
-
<% bids.each do |bid|%>
-
-<%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %>
-
-
-
-<%= link_to(bid.author, user_path(bid.author), :class => 'bid_user') %>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
-
-
-
-
-
- <% if bid.reward_type.nil? or bid.reward_type == 1%>
- <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%>
- <% elsif bid.reward_type == 2%>
- <%= l(:label_bids_reward_method) %><%= bid.budget%>
- <% else %>
- <%= l(:label_bids_reward_method) %><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %>
- <% end %>
-
-
-
-
-
- <%= l(:label_x_biding_project, :count => bid.biding_projects.count) %>(<%=link_to bid.biding_projects.count, project_for_bid_path(bid) %> )
- <%= l(:label_x_responses, :count => bid.commit) %>(<%=link_to bid.commit, respond_path(bid) %> )
- <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%=link_to bid.watcher_users.count, respond_path(bid) %> )
-
-
-
- <%= format_time bid.created_on %>
-
-
-
-
-
-
- <%= bid.description%>
-
-
-
-
-
-
-
-<% end %>
-
-
-
- <% end %>
+
+ <% unless bid.reward_type == 3 %>
+
+ <%= l(:label_x_biding_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid) %> ) <%= l(:label_x_bids_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %> ) <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%= link_to bid.watcher_users.count, respond_path(bid) %> )
+
+ <% else %>
+
+ <%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid) %> ) <%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %> ) <%= l(:label_x_followers, :count => bid.watcher_users.count) %>(<%= link_to bid.watcher_users.count, respond_path(bid) %> )
+
+ <% end %>
+
+ <%= format_time bid.created_on %>
- <%= l(:field_deadline) %><%= format_time bid.created_on %>
+
+
+
+
+ <%= bid.description%>
+
+
+
@@ -104,4 +45,5 @@
<%= pagination_links_full bid_pages %>
- -->
+
+
diff --git a/app/views/bids/_form.html.erb b/app/views/bids/_form.html.erb
index 3f9d66998..04ea7d7c9 100644
--- a/app/views/bids/_form.html.erb
+++ b/app/views/bids/_form.html.erb
@@ -26,7 +26,7 @@
<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_requirement_name)}" %>
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_requirement_description)}" %>
-<%= select_tag 'bid_reward_type', "#{l(:label_choose_reward)} #{l(:label_money)} #{l(:label_bids_credit)} #{l(:label_reward_1)} ".html_safe,
+
<%= select_tag 'bid_reward_type', "#{l(:label_choose_reward)} #{l(:label_money)} #{l(:label_reward_1)} ".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) %>
diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb
index f36ae1acc..3d9ed4212 100644
--- a/app/views/bids/_history.html.erb
+++ b/app/views/bids/_history.html.erb
@@ -5,9 +5,16 @@
when the manager closed it or to the deadline.
-->
-
-
- <%=l(:label_user_response)%>
+
+
+
+ <% if @bid.reward_type ==3 %>
+ <%=l(:label_student_response)%>
+ <% else %>
+ <%=l(:label_user_response)%>
+ <% end %>
+
+
@@ -24,8 +31,13 @@
<%= link_to image_tag(url_to_avatar(journal.user), :class => "avatar"), user_path(journal.user), :class => "avatar" %>
- <%=link_to journal.user, user_path(journal.user)%> <%= l(:label_respond_requirement) %>
+ <% if @bid.reward_type == 3 %>
+ <%=link_to journal.user, user_path(journal.user)%> <%= l(:label_question_requirement) %>
+ <% else %>
+ <%=link_to journal.user, user_path(journal.user)%> <%= l(:label_respond_requirement) %>
+ <% end %>
+
<%= textilizable journal.notes%>
diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb
new file mode 100644
index 000000000..3d6ded4fc
--- /dev/null
+++ b/app/views/bids/_homework.html.erb
@@ -0,0 +1,22 @@
+
+<% 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 = ?', 5, 7)).size >0) %>
+
+
+ <%= toggle_link l(:button_bidding_homework), 'put-bid-form' %>
+
+<% elsif @homework_list.empty? %>
+
+<% end %>
+
+
+ <%= render :partial => 'homework_list', :locals => {:homework => @homework_list} %>
+
diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb
new file mode 100644
index 000000000..3e9713bdd
--- /dev/null
+++ b/app/views/bids/_homework_list.html.erb
@@ -0,0 +1,30 @@
+
+<%= render_flash_messages %>
+
+<% @homework_list.each do |homework|%>
+ <% if homework.attachments.any?%>
+
+
+
+ <%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar"), user_path(homework.user), :class => "avatar" %>
+
+
+
+ <%= link_to homework.user, user_path(homework.user)%> 提交了作业
+
+
+
+
+ <% options = {:author => true, :deletable => attach_delete(homework)} %>
+ <%= render :partial => 'attachments/links',
+ :locals => {:attachments => homework.attachments, :options => options} %>
+ <% end %>
+
+
+
+
+
+
+
+
+<% end %>
diff --git a/app/views/bids/_new.html.erb b/app/views/bids/_new.html.erb
index ad48a979f..d57a26d72 100644
--- a/app/views/bids/_new.html.erb
+++ b/app/views/bids/_new.html.erb
@@ -65,14 +65,18 @@
<% if User.current.logged? %>
- <%= f.text_area 'message', :rows => 3, :cols => 65, :value => "#{l(:label_my_respond)}", :onfocus => "clearInfo('bid_message_message', '#{l(:label_my_respond)}')", :onblur => "showInfo('bid_message_message', '#{l(:label_my_respond)}')", :style => "resize: none;", :class => 'noline'%>
+ <% if @bid.reward_type ==3 %>
+ <%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_question), :style => "resize: none;", :class => 'noline'%>
+ <% else %>
+ <%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%>
+ <% end %>
<%= f.text_field :reference_user_id, :style=>"display:none"%>
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%>
- <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('bid_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
+ <%= submit_tag l(:button_clear_requirement), :name => nil, :onclick => "clearMessage('bid_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
<% else %>
diff --git a/app/views/bids/_project_homework.html.erb b/app/views/bids/_project_homework.html.erb
new file mode 100644
index 000000000..bfe86c75c
--- /dev/null
+++ b/app/views/bids/_project_homework.html.erb
@@ -0,0 +1,51 @@
+
+<%= render_flash_messages %>
+
+ <%= l(:label_bidding_project) %>(<%= @bidding_project.count%>)
+ <% if User.current.logged? %>
+
+
+ <%= toggle_link l(:button_bidding), 'put-bid-form' %>
+
+ <% end %>
+
+
+<% @bidding_project.each do |b_project|%>
+
+
+
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %>
+
+
+
+
+
+
+
+ <%= l(:label_bidding_user) %><%= link_to(b_project.user.name, user_path(b_project.user)) %>
+
+
+ <%= l(:label_bidding_reason) %><%= b_project.description %>
+
+
+
+
+
+
+
+<% end %>
diff --git a/app/views/bids/_project_list.html.erb b/app/views/bids/_project_list.html.erb
index 59a282143..23e1b4f24 100644
--- a/app/views/bids/_project_list.html.erb
+++ b/app/views/bids/_project_list.html.erb
@@ -1,12 +1,68 @@
<%= render_flash_messages %>
-
+
<% if @bid.deadline > Date.today %>
<%= l(:label_bidding_project) %>(<%= @bidding_project.count%>)
+ <%= l(:label_homework_project) %>(<%= @bidding_project.count%>)
+ <% if User.current.logged? %>
+
+ <% 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 = ?', 5, 7)).size >0) %>
+
+ <%= toggle_link l(:button_bidding_homework), 'put-bid-form' %>
+
+ <% end %>
+
+ <% end %>
+
+
+<% @bidding_project.each do |b_project|%>
+
+
+
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %>
+
+
+
+
+
+
+
+ <%= l(:label_bidding_user_homework) %> : <%= link_to(b_project.user.name, user_path(b_project.user)) %>
+
+
+ <%= l(:label_bidding_reason_homewrok) %> : <%= b_project.description %>
+
+
+
+
+
+
+
+<% end %>
+
+
+
+ <% else %>
+
<%= l(:label_bidding_project) %>(<%= @bidding_project.count%>)
<% if User.current.logged? %>
@@ -29,6 +85,6 @@
<% end %>
-
+
<%= render :partial=> "list_projects",:locals => {:bidding_project => @bidding_project,:bid => @bid }%>
diff --git a/app/views/bids/add_homework.js.erb b/app/views/bids/add_homework.js.erb
new file mode 100644
index 000000000..f553f6695
--- /dev/null
+++ b/app/views/bids/add_homework.js.erb
@@ -0,0 +1,4 @@
+$('#bidding_project_list').html('<%= escape_javascript(render(:partial => 'homework_list', :locals => {:homework => @homework_list})) %>');
+$("#project_id").val("请选择项目");
+$("#bid_message").val("#{l(:label_bid_reason)} ");
+$("#put-bid-form").hide();
\ No newline at end of file
diff --git a/app/views/bids/homework_respond.html.erb b/app/views/bids/homework_respond.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/bids/homework_statistics.html.erb b/app/views/bids/homework_statistics.html.erb
new file mode 100644
index 000000000..9f98364cc
--- /dev/null
+++ b/app/views/bids/homework_statistics.html.erb
@@ -0,0 +1,4 @@
+未交作业人数(
+<% %>)
+
+已交作业人数
\ No newline at end of file
diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb
index 0c2648874..5a1e12a7f 100644
--- a/app/views/bids/show.html.erb
+++ b/app/views/bids/show.html.erb
@@ -4,7 +4,7 @@
<%= link_to image_tag(url_to_avatar(@bid.author), :class => "avatar"), user_path(@bid.author), :class => "avatar" %>
- <%= link_to(@bid.author.name, user_path(@bid.author))%>:<%= @bid.name %>
+ <%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%>:<%= @bid.name %>
@@ -13,6 +13,7 @@
+
<% if @bid.reward_type.nil? or @bid.reward_type == 1%>
@@ -40,7 +41,13 @@
- <%= @bid.description %>
+ <%= @bid.description %>
+ <% if @bid.attachments.any?%>
+ <% options = {:author => true} %>
+ <%= render :partial => 'attachments/links',
+ :locals => {:attachments => @bid.attachments, :options => options} %>
+ <% end %>
+
diff --git a/app/views/bids/show_document_homework.html.erb b/app/views/bids/show_document_homework.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb
index 9dc4172bf..77f634e4d 100644
--- a/app/views/bids/show_project.html.erb
+++ b/app/views/bids/show_project.html.erb
@@ -1,4 +1,9 @@
+
+<% if @bid.homework_type == 1%>
+<%= render :partial => 'homework' %>
+
+<% else %>
+
+
+
+<% if User.current.logged? %>
+
+
+<% end %>
+
+
+ <%= render :partial => 'project_list', :locals => {:bidding_project => @bidding_project} %>
+
diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb
new file mode 100644
index 000000000..50bb692d4
--- /dev/null
+++ b/app/views/courses/_set_join.js.erb
@@ -0,0 +1,8 @@
+$('#join').html('<%= escape_javascript join_in_course(course, user) %>');
+<% if @state %>
+ <% if @state == 0 %>
+ alert("加入成功")
+ <% else %>
+ alert("密码错误")
+ <% end %>
+<% end %>
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index 001ae9596..bf42c5dbd 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -1,6 +1,14 @@
-
-<%= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
+<% if @project.project_type == 1 %>
+
+ <% if User.current.member_of?(@project) %>
+<%= link_to(l(:label_file_upload), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
+ <% end %>
+<% else %>
+
+<%= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
+
+<% end %>
<%=l(:label_attachment_plural)%>
@@ -11,8 +19,8 @@
<%= sort_header_tag('filename', :caption => l(:field_filename)) %>
<%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc') %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %>
- <%= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %>
-
MD5
+
+
<%= sort_header_tag('description', :caption => l(:field_description)) %>
@@ -30,8 +38,8 @@
<%= link_to_attachment file, :download => true, :title => file.description %>
<%= format_time(file.created_on) %>
<%= number_to_human_size(file.filesize) %>
- <%= file.downloads %>
- <%= file.digest %>
+
+ <%= file.description %>
<%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
@@ -44,3 +52,4 @@
<% html_title(l(:label_attachment_plural)) -%>
+
diff --git a/app/helpers/issue_categories_helper.rb b/app/views/issue_categories/issue_categories_helper.rb
similarity index 100%
rename from app/helpers/issue_categories_helper.rb
rename to app/views/issue_categories/issue_categories_helper.rb
diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb
index eff2cd6f7..36be8c5f0 100644
--- a/app/views/layouts/base_bids.html.erb
+++ b/app/views/layouts/base_bids.html.erb
@@ -64,7 +64,7 @@
<%= link_to l(:label_x_followers, :count => @bid.watcher_users.count)+"("+@bid.watcher_users.count.to_s+")", respond_path(@bid) %>
<%= link_to l(:label_bidding_project)+"("+@bid.biding_projects.count.to_s+")", project_for_bid_path(@bid) %>
- <%= link_to l(:label_x_responses, :count => @bid.commit)+"("+@bid.commit.to_s+")", respond_path(@bid)%>
+ <%= link_to l(:label_x_bids_responses, :count => @bid.commit)+"("+@bid.commit.to_s+")", respond_path(@bid)%>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
new file mode 100644
index 000000000..f634d1975
--- /dev/null
+++ b/app/views/layouts/base_courses.html.erb
@@ -0,0 +1,180 @@
+
+
+
+
+
<%= h html_title %>
+
+
+ <%= csrf_meta_tag %>
+ <%= favicon %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
+ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
+ <%= javascript_heads %>
+ <%= heads_for_theme %>
+ <%= call_hook :view_layouts_base_html_head %>
+
+ <%= yield :header_tags -%>
+
+
+
+
+
+
+ <%= render :partial => 'layouts/base_header'%>
+
+
+
+
+
+
+
+ <%= link_to l(:label_course_overview), project_path(@project), :class => link_class(:overview)%>
+ <%= link_to l(:label_homework), {:controller => 'projects', :action => 'homework'}, :class => link_class('Homework')%>
+ <%= link_to l(:label_course_file), project_files_path(@project), :class => link_class(:files)%>
+ <%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news)%>
+
+ <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))%>
+ <%= link_to l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project}, :class => link_class(:settings)%>
+ <% end %>
+
+ <%= yield %>
+ <%= call_hook :view_layouts_base_content %>
+
+ <%= render_flash_messages %>
+
+
+ <%= render :partial => 'layouts/base_footer'%>
+
+
+
+ <%= l(:label_loading) %>
+
+
+
+
+ <%= call_hook :view_layouts_base_body_bottom %>
+
+
\ No newline at end of file
diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb
new file mode 100644
index 000000000..a20f4e6f4
--- /dev/null
+++ b/app/views/layouts/base_homework.html.erb
@@ -0,0 +1,143 @@
+
+
+
+
+
<%= h html_title %>
+
+
+ <%= csrf_meta_tag %>
+ <%= favicon %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
+ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
+ <%= javascript_heads %>
+ <%= heads_for_theme %>
+ <%= call_hook :view_layouts_base_html_head %>
+
+ <%= yield :header_tags -%>
+
+
+
+
+
+
+ <%= render :partial => 'layouts/base_header'%>
+
+
+
+
+
+
+
+
+ <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show' },:class => link_class(:respond)%>
+
+
+ <% 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 = ?', 5, 7)).size >0) %>
+ <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%>
+ <% else %>
+ <%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%>
+
+ <% end %>
+
+
+
+
+ <%= yield %>
+ <%= call_hook :view_layouts_base_content %>
+
+
+ <%= render :partial => 'layouts/base_footer'%>
+
+
+
+
+
+ <%= l(:label_loading) %>
+
+
+
+
+ <%= call_hook :view_layouts_base_body_bottom %>
+
+
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb
index 2cedd1815..7faf4b4e6 100644
--- a/app/views/layouts/base_users.html.erb
+++ b/app/views/layouts/base_users.html.erb
@@ -96,10 +96,10 @@
- <%= l(:label_user_joinin) %>
+ <%= l(:label_user_joinin) %>
- <%= l(:label_user_login) %>
+ <%= l(:label_user_login) %>
<%= l(:label_user_mail) %>
diff --git a/app/views/mailer/journals_for_message_added.html.erb b/app/views/mailer/journals_for_message_added.html.erb
new file mode 100644
index 000000000..f68026492
--- /dev/null
+++ b/app/views/mailer/journals_for_message_added.html.erb
@@ -0,0 +1,2 @@
+<%= link_to("hello", @url) %>
+<%=h @user %>
diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb
index b4f55ebe8..df80a7483 100644
--- a/app/views/news/_form.html.erb
+++ b/app/views/news/_form.html.erb
@@ -2,7 +2,7 @@
<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>
-
<%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %>
+
<%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit', :style => "width:490px;" %>
<%= l(:label_attachment_plural) %> <%= render :partial => 'attachments/form', :locals => {:container => @news} %>
diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb
index 64d633575..cded25576 100644
--- a/app/views/news/index.html.erb
+++ b/app/views/news/index.html.erb
@@ -1,12 +1,24 @@
-<%= link_to(l(:label_news_new),
+ <% if @project.project_type == 1%>
+<%= link_to(l(:label_news_notice),
new_project_news_path(@project),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-news", "news_title"); return false;') if @project && User.current.allowed_to?(:manage_news, @project) %>
+ <% else %>
+ <%= link_to(l(:label_news_new),
+ new_project_news_path(@project),
+ :class => 'icon icon-add',
+ :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') if @project && User.current.allowed_to?(:manage_news, @project) %>
+
+ <% end %>
+<% if @project.project_type == 1 %>
+
<%=l(:bale_news_notice)%>
+<% else %>
<%=l(:label_news_new)%>
+<% end %>
<%= labelled_form_for @news, :url => project_news_index_path(@project),
:html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
@@ -39,13 +51,19 @@
<%= l(:label_no_data) %>
<% else %>
<% @newss.each do |news| %>
-
+
<%=link_to image_tag(url_to_avatar(news.author), :class => "avatar"), user_path(news.author) %>
+ <% if @project.project_type == 1 %>
+ <%=link_to_user(news.author)if news.respond_to?(:author) %> <%= l(:label_project_notice)%> <%= link_to h(news.title), news_path(news) %>
+
+ <% else %>
+
<%=link_to_user(news.author)if news.respond_to?(:author) %> <%= l(:label_project_newshare)%> <%= link_to h(news.title), news_path(news) %>
-
+
+ <% end %>
<%= textilizable(news, :description) %>
diff --git a/app/views/projects/_course_form.html.erb b/app/views/projects/_course_form.html.erb
new file mode 100644
index 000000000..efc537113
--- /dev/null
+++ b/app/views/projects/_course_form.html.erb
@@ -0,0 +1,58 @@
+<%= error_messages_for 'project' %>
+<%= error_messages_for 'course' %>
+
+
+<% unless @project.new_record? %>
+<%= render :partial=>"avatar/avatar_form",:locals=> {source:@project} %>
+<% end %>
+<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %>
+
+<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= f.fields_for @course do |m| %>
+
+
+ <%= m.text_field :state, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %>
+ <%= l(:text_command) %>
+ <%= m.text_field :term, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %>
+
+<% end %>
+
+<%= f.text_field :project_type, :value => 1 %>
+
+
+<%= wikitoolbar_for 'project_description' %>
+
+<% @project.custom_field_values.each do |value| %>
+ <%= custom_field_tag_with_label :project, value %>
+<% end %>
+<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
+
+
+
+
+
+<% unless @project.identifier_frozen? %>
+ <% content_for :header_tags do %>
+ <%= javascript_include_tag 'project_identifier' %>
+ <% end %>
+<% end %>
+
+<% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %>
+ <%= javascript_tag do %>
+ $(document).ready(function() {
+ $("#project_inherit_members").change(function(){
+ if (!$(this).is(':checked')) {
+ if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) {
+ $("#project_inherit_members").attr("checked", true);
+ }
+ }
+ });
+ });
+ <% end %>
+<% end %>
diff --git a/app/views/projects/_edit.html.erb b/app/views/projects/_edit.html.erb
index 8661b6874..1ec8b1ee8 100644
--- a/app/views/projects/_edit.html.erb
+++ b/app/views/projects/_edit.html.erb
@@ -1,6 +1,10 @@
<%= labelled_form_for @project do |f| %>
-<%= render :partial => 'form', :locals => { :f => f } %>
-<%= submit_tag l(:button_save) %>
+ <% if @project.project_type == 1%>
+ <%= render :partial => 'course_form', :locals => { :f => f } %>
+ <% else %>
+ <%= render :partial => 'form', :locals => { :f => f } %>
+ <% end %>
+ <%= submit_tag l(:button_save) %>
<% end %>
-
\ No newline at end of file
+
diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb
index 8d9ee0dfc..2ccd84032 100644
--- a/app/views/projects/_form.html.erb
+++ b/app/views/projects/_form.html.erb
@@ -10,9 +10,9 @@
<% unless @project.identifier_frozen? %>
<%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %>
<% end %>
-<%= f.text_field :homepage, :size => 60, :style => "width:488px;margin-left: 10px;" %>
-<%= f.check_box :is_public, :style => "margin-left:10px;" %>
-
+
+<%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %>
+<%= f.text_field :project_type, :value => 0 %>
<%= wikitoolbar_for 'project_description' %>
diff --git a/app/views/projects/_homework_form.html.erb b/app/views/projects/_homework_form.html.erb
new file mode 100644
index 000000000..e4a471367
--- /dev/null
+++ b/app/views/projects/_homework_form.html.erb
@@ -0,0 +1,41 @@
+
+
+
+
+<%= error_messages_for 'bid' %>
+
+<%= l(:label_homeworks_form_new_description) %>
+<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %>
+
+<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %>
+
+<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>
+
+<%= f.select :homework_type, homework_type_option %>
+
+<%= hidden_field_tag 'course_id', @project.id %>
+
+<%= l(:label_attachment_plural) %>
+<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>
+
\ No newline at end of file
diff --git a/app/views/projects/_new_homework.html.erb b/app/views/projects/_new_homework.html.erb
new file mode 100644
index 000000000..1da188f3b
--- /dev/null
+++ b/app/views/projects/_new_homework.html.erb
@@ -0,0 +1,81 @@
+
+
+
+
+
+<%= form_tag({:controller => 'bids',
+:action => 'new_bid',
+:remote => true,
+:method => :post,
+:id => 'new-bid-form'}) do %>
+
+
+
+ <%= text_field_tag 'bid_title', "#{l(:label_requirement_name)}", :class => 'noline', :required => true, :onfocus => "clearInfo('bid_title', '#{l(:label_requirement_name)}')", :onblur => "showInfo('bid_title', '#{l(:label_requirement_name)}')"%>
+
+
+
+
+
+ <%= text_area_tag 'bid_description', "#{l(:label_requirement_description)}", :class => 'noline', :required => true, :style => "resize: none;", :rows => 6,
+ :onfocus => "clearInfo('bid_description', '#{l(:label_requirement_description)}')", :onblur => "showInfo('bid_description', '#{l(:label_requirement_description)}')" %>
+
+
+
+
+
+
+
+
+
+ <%= text_field_tag 'bid_deadline', "#{l(:label_deadline)}", :class => 'noline', :required => true,
+ :onfocus => "clearInfo('bid_deadline', '#{l(:label_deadline)}')", :onblur => "showInfo('bid_deadline', '#{l(:label_deadline)}')"%>
+ <%= calendar_for('bid_deadline')%>
+
+
+
+
+ <%= submit_tag l(:button_new_bid), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%>
+
+
+<%end%>
\ No newline at end of file
diff --git a/app/views/projects/_new_join.html.erb b/app/views/projects/_new_join.html.erb
new file mode 100644
index 000000000..ca06715f3
--- /dev/null
+++ b/app/views/projects/_new_join.html.erb
@@ -0,0 +1,54 @@
+
+
+
+请输入课程密码
+
+<%= form_tag({:controller => 'courses',
+ :action => 'join',
+ :object_id => course.id},
+ :remote => true,
+ :method => :post,
+ :id => 'new-watcher-form') do %>
+
+ <%= text_field_tag 'course_password', nil, :size => 48%>
+
+
+ <%= submit_tag '加入', :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %>
+ <%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %>
+
+<% end %>
diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb
index 0a1384353..8042cfe4d 100644
--- a/app/views/projects/_project.html.erb
+++ b/app/views/projects/_project.html.erb
@@ -25,7 +25,14 @@
- <%= content_tag('span', "#{l(:default_role_manager)}: ") %>
+
+ <% if(@project.project_type==1)%>
+ <%= content_tag('span', "#{l(:field_tea_name)}: ") %>
+ <% else %>
+ <%= content_tag('span', "#{l(:default_role_manager)}: ") %>
+ <% end %>
+
+
<% @admin = @project.project_infos%>
<% if @admin.size > 0 %>
<%= content_tag('a', @admin.collect{|u| link_to(u.user.name, user_path(u.user_id))}.join(", ").html_safe) %>
diff --git a/app/views/projects/homework.html.erb b/app/views/projects/homework.html.erb
new file mode 100644
index 000000000..8db482544
--- /dev/null
+++ b/app/views/projects/homework.html.erb
@@ -0,0 +1,28 @@
+
+
+
+
+
+ <%= l(:label_course_homework_list)%>
+ <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))%>
+
+
+ <%= link_to(l(:label_course_homework_new), {:controller => 'projects', :action => 'new_homework'}, :class => 'icon icon-add') %>
+
+
+ <% end %>
+
+
+
+
+ <%= text_field_tag 'name', params[:name], :size => 30 %>
+ <%= submit_tag l(:label_search), :class => "small", :name => nil %>
+
+
+
+
+
+
+ <%= render :partial => 'bids/bid_homework_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
+
+
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index f0e24bdca..bac032778 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -7,8 +7,8 @@
<%= l(:label_project_plural)%>
- <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
-
+ <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
+ <%= link_to(l(:label_course_new), {:controller => 'projects', :action => 'new', :course => 1}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
<%= text_field_tag 'name', params[:name], :size => 30 %>
@@ -17,7 +17,7 @@
-<%end%>
+<% end %>
<%= sort_project(@s_type)%>
+
diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb
index 4f34d4988..027559317 100644
--- a/app/views/projects/new.html.erb
+++ b/app/views/projects/new.html.erb
@@ -1,12 +1,19 @@
-
<%=l(:label_project_new)%>
-
<%= labelled_form_for @project do |f| %>
-
- <%= render :partial => 'form', :locals => { :f => f } %>
- <%= submit_tag l(:button_create) %>
- <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
- <%= javascript_tag "$('#project_name').focus();" %>
- <% end %>
-
+ <% if @course_tag == '1' %>
+
<%=l(:label_course_new)%>
+
+ <%= render :partial => 'course_form', :locals => { :f => f } %>
+ <%= submit_tag l(:button_create) %>
+ <%= submit_tag l(:button_create_and_continue), :name => 'course_continue' %>
+ <% else %>
+
<%=l(:label_project_new)%>
+
+ <%= render :partial => 'form', :locals => { :f => f } %>
+ <%= submit_tag l(:button_create) %>
+ <%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
+ <% end %>
+ <%= javascript_tag "$('#project_name').focus();" %>
+
+<% end %>
diff --git a/app/views/projects/new_homework.html.erb b/app/views/projects/new_homework.html.erb
new file mode 100644
index 000000000..3737a6509
--- /dev/null
+++ b/app/views/projects/new_homework.html.erb
@@ -0,0 +1,9 @@
+
<%=l(:label_course_new_homework)%>
+
+<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework'} do |f| %>
+
+ <%= render :partial => 'homework_form', :locals => { :f => f } %>
+ <%= submit_tag l(:button_create) %>
+ <%= javascript_tag "$('#bid_name').focus();" %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/projects/new_join.js.erb b/app/views/projects/new_join.js.erb
new file mode 100644
index 000000000..c0a6f4a50
--- /dev/null
+++ b/app/views/projects/new_join.js.erb
@@ -0,0 +1,3 @@
+$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', :locals => {:course => @course}) %>');
+showModal('ajax-modal', '400px');
+$('#ajax-modal').addClass('new-watcher');
diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb
index d95ccb6ac..6682ced76 100644
--- a/app/views/projects/settings.html.erb
+++ b/app/views/projects/settings.html.erb
@@ -1,3 +1,7 @@
<%=l(:label_settings)%>
-<%= render_tabs project_settings_tabs %>
+<% if @project.project_type == 1 %>
+ <%= render_tabs course_settings_tabs %>
+<% else %>
+ <%= render_tabs project_settings_tabs %>
+<% end %>
<% html_title(l(:label_settings)) -%>
diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb
index e4b00fdb6..c4670e85c 100644
--- a/app/views/projects/settings/_members.html.erb
+++ b/app/views/projects/settings/_members.html.erb
@@ -17,7 +17,22 @@
<%= l(:label_role_plural) %>:
<% roles.each do |role| %>
- <%= check_box_tag 'membership[role_ids][]', role.id %> <%=h role %>
+
+ <% if @project.project_type == 1 %>
+ <% if role == Role.find(3) %>
+ <%= check_box_tag 'membership[role_ids][]', role.id %>Teacher
+ <% elsif role == Role.find(5) %>
+ <%= check_box_tag 'membership[role_ids][]', role.id %>Student
+ <% elsif role == Role.find(4)%>
+ <% else %>
+ <%= check_box_tag 'membership[role_ids][]', role.id %><%=h role %>
+ <% end %>
+ <% else %>
+ <% if role == Role.find(7) %>
+ <% else %>
+ <%= check_box_tag 'membership[role_ids][]', role.id %><%=h role %>
+ <% end %>
+ <% end %>
<% end %>
@@ -40,11 +55,39 @@
<%= link_to_user member.principal %>
- <%=h member.roles.sort.collect(&:to_s).join(', ') %>
+
+ <% if @project.project_type == 1 %>
+
+ <% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
+ Teacher
+ <% elsif member.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
+ Student
+ <% elsif member.roles.sort.collect(&:to_s).join(', ') =='TA' %>
+ TA
+ <% else %>
+
+ <% end %>
+
+ <% else %>
+
+ <% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
+ Manager
+ <% elsif member.roles.sort.collect(&:to_s).join(', ') =='Developer' %>
+ Developer
+ <% elsif member.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
+ Reporter
+ <% else %>
+ <% end %>
+
+ <% end %>
+
+
+
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => { :id => "member-#{member.id}-roles-form", :class => 'hol' }}
) do |f| %>
+
<% roles.each do |role| %>
<%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
:disabled => member.member_roles.detect {|mr| mr.role_id == role.id && !mr.inherited_from.nil?} %> <%=h role %>
diff --git a/app/views/projects/settings/_repositories.html.erb b/app/views/projects/settings/_repositories.html.erb
index c0f4d263b..83da6f79d 100644
--- a/app/views/projects/settings/_repositories.html.erb
+++ b/app/views/projects/settings/_repositories.html.erb
@@ -55,11 +55,12 @@
<%= l(:label_no_data) %>
<% end %>
+<% course_tag = @project.project_type %>
<% if User.current.allowed_to?(:manage_repository, @project) %>
- <%= link_to l(:label_repository_new), new_project_repository_path(@project), :class => 'icon icon-add' %>
+ <%= link_to l(:label_repository_new), new_project_repository_path(@project, :course => course_tag), :class => 'icon icon-add' %>
<% end %>
<% if User.current.allowed_to?(:manage_repository, @project) %>
<%= l(:label_repository_no) %>
- <%= link_to l(:label_repository_new_repos), newrepo_project_repository_path(@project), :class => 'icon icon-add' %>
+ <%= link_to l(:label_repository_new_repos), newrepo_project_repository_path(@project, :course => course_tag), :class => 'icon icon-add' %>
<% end %>
\ No newline at end of file
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb
index 259a6b801..8a8ae2a40 100644
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -10,7 +10,7 @@
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
-
+
<%= image_tag(url_to_avatar(e.event_author), :class => "avatar")%>
diff --git a/app/views/projects/statistics.html.erb b/app/views/projects/statistics.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/repositories/_navigation.html.erb b/app/views/repositories/_navigation.html.erb
index a42daa8f5..e46e0dac2 100644
--- a/app/views/repositories/_navigation.html.erb
+++ b/app/views/repositories/_navigation.html.erb
@@ -3,7 +3,7 @@
<% end %>
<%= link_to l(:label_statistics),
- {:action => 'stats', :id => @project, :repository_id => @repository.identifier_param},
+ {:controller => 'repositories', :action => 'stats', :id => @project, :repository_id => @repository.identifier_param},
:class => 'icon icon-stats' if @repository.supports_all_revisions? %>
<%= form_tag({:action => controller.action_name,
diff --git a/app/views/repositories/stats.html.erb b/app/views/repositories/stats.html.erb
index 8299af0f6..d790f3d57 100644
--- a/app/views/repositories/stats.html.erb
+++ b/app/views/repositories/stats.html.erb
@@ -1,12 +1,6 @@
<%= l(:label_statistics) %>
-
-<%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %>
-
-
-<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_author")) %>
-
-
-<%= link_to l(:button_back), :action => 'show', :id => @project %>
+<% src = "http://localhost:3000/statistics/"+@project_id+"/index.html"%>
+
<% html_title(l(:label_repository), l(:label_statistics)) -%>
diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb
index d123b9053..49a81da2a 100644
--- a/app/views/tags/_tag_name.html.erb
+++ b/app/views/tags/_tag_name.html.erb
@@ -35,7 +35,7 @@
<% end %>
<% else %>
- <%= l(:label_tags_no) %>
+ <%= l(:label_tags_no) %>
<% end %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb
new file mode 100644
index 000000000..1e155c5d9
--- /dev/null
+++ b/app/views/users/_my_course.html.erb
@@ -0,0 +1,57 @@
+
+ <% unless @memberships.empty? %>
+
+ <% for membership in @memberships %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(membership.project), :class => 'avatar'), project_path(membership.project) %>
+
+
+
+ <%= link_to_project(membership.project) %>
+ <%= l(:label_homework) %> (<%= link_to (membership.project.homeworks.count), {:controller => 'projects', :action => 'homework', :id => membership.project.identifier} %> )
+
+ <%= l(:label_course_news)%> (<%= link_to (membership.project.news.count), {:controller => 'news', :action => 'index', :project_id => membership.project.identifier} %> )
+
+
+
+
+
+ <%= membership.project.description%>
+
+
+
+ <%= format_time(membership.created_on) %>
+
+
+ <% if membership.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
+ Teacher
+ <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
+ Student
+ <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='TA' %>
+ TA
+ <% end %>
+
+
+
+
+
+
+
+
+ <% end %>
+
+ <% else %>
+ <% if @user != User.current %>
+
+ <%= l(:label_project_course_un) %>
+
+ <% else %>
+
+ <%= l(:label_project_course_unadd) %><%= link_to"#{l(:label_new)}",:controller=>'projects',:action=>'new', :course => 1 %>
+
+ <% end %>
+ <% end %>
+ <%= call_hook :view_account_left_bottom, :user => @user %>
+
diff --git a/app/views/users/_my_homework.html.erb b/app/views/users/_my_homework.html.erb
new file mode 100644
index 000000000..4c4bd2138
--- /dev/null
+++ b/app/views/users/_my_homework.html.erb
@@ -0,0 +1,48 @@
+
+<% if @bid.size > 0%>
+
+<% @bid.each do |bids|%>
+<%= link_to(Project.find(bids[0]).name, project_path(bids[0])) %>
+
+<% for bid in bids[1]%>
+
+
+
+ <%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %>
+
+
+
+ <%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
+
+
+
+
+
+ <% if bid.reward_type.nil? or bid.reward_type == 1 %> <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%> <% elsif bid.reward_type == 2 %> <%= l(:label_bids_reward_method) %><%= bid.budget%> <% else %> <% end %>
+
+
+ <%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %> ) <%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %> )
+
+
+ <%= format_time bid.created_on %>
+
+
+
+
+
+
+ <%= bid.description%>
+
+
+
+
+
+
+
+
+<% end %>
+<% end %>
+
+<% else %>
+暂无任何作业
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/_my_notice.html.erb b/app/views/users/_my_notice.html.erb
new file mode 100644
index 000000000..c317865e7
--- /dev/null
+++ b/app/views/users/_my_notice.html.erb
@@ -0,0 +1,48 @@
+
+
+<% unless @memberships.empty? %>
+
+ <% for membership in @memberships %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(membership.project), :class => 'avatar'), project_path(membership.project) %>
+
+
+
+ <%= link_to_project(membership.project) %>
+ <%= l(:label_homework) %> (8 )
+ <%= l(:label_course_news)%> (8 )
+ <%= l(:label_member)%>(<%=link_to (membership.project.members.count)%> )
+
+
+
+
+
+
+
+ <%= membership.project.description%>
+
+
+
+ <%= format_time(membership.created_on) %>
+ <%= h membership.roles.sort.collect(&:to_s).join(', ') %>
+
+
+
+
+
+
+
+ <% end %>
+
+<% else %>
+<% if @user != User.current %>
+
<%= l(:label_project_un) %>
+<% else %>
+
<%= l(:label_project_unadd) %><%= link_to"#{l(:label_new)}",:controller=>'projects',:action=>'new'%>
+<% end %>
+
+<% end %>
+<%= call_hook :view_account_left_bottom, :user => @user %>
+
diff --git a/app/views/users/info.html.erb b/app/views/users/info.html.erb
index d3940caf5..e63b71817 100644
--- a/app/views/users/info.html.erb
+++ b/app/views/users/info.html.erb
@@ -2,7 +2,7 @@
<% unless @message.empty? %>
<% @message.each do |e| -%>
-
+
<%= link_to image_tag(url_to_avatar(e.user), :class => "avatar"), user_path(e.user), :class => "avatar" %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 6bd74fdb8..14b3556e5 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -7,7 +7,7 @@
<% @activity.each do |e| %>
<% act = e.act %>
<% unless act.nil? %>
-
+
<%= link_to image_tag(url_to_avatar(e.user), :class => "avatar"), user_path(e.user_id), :class => "avatar" %>
diff --git a/app/views/users/user_courses.html.erb b/app/views/users/user_courses.html.erb
new file mode 100644
index 000000000..409a38acd
--- /dev/null
+++ b/app/views/users/user_courses.html.erb
@@ -0,0 +1,11 @@
+
+
+<%= user_course @state%>
+<% if @state == 0 %>
+<%= render :partial => 'my_course' %>
+<% elsif @state == 1 %>
+<%= render :partial => 'my_homework' %>
+<% else @state == 2 %>
+<%= render :partial => 'my_notice' %>
+<% end %>
+
diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb
index 55340902b..643ccfe96 100644
--- a/app/views/users/user_newfeedback.html.erb
+++ b/app/views/users/user_newfeedback.html.erb
@@ -6,7 +6,7 @@
<%= l(:label_newfeedback_message) %>(<%= @feedback_count%>)
-
+
<%= render :partial => 'words/message', :locals => {:jour => @jour, :state => @state, :user => @user, :feedback_pages => @feedback_pages} %>