diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 83af48ae4..2e6f4b59d 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -176,7 +176,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|
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index efe32a80b..a7c28cee0 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -559,7 +559,8 @@ class ProjectsController < ApplicationController
if validate_parent_id && @project.save
@course = Course.find_by_extra(@project.identifier)
@course.state = params[:project][:course][:state]
- @course.save
+ @course.term = params[:project][:course][:term]
+ @course.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
respond_to do |format|
format.html {
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 80838947f..cc271a1c0 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -122,6 +122,17 @@ class UsersController < ApplicationController
# 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))
@@ -133,13 +144,13 @@ class UsersController < ApplicationController
end
@bid = []
@memberships.each do |membership|
- @bid += membership.project.homeworks
+ @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))
-
+ @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
@memberships = []
@membership.each do |membership|
if membership.project.project_type == 1
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index c1388f6eb..a1befebc7 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -102,6 +102,10 @@ module UsersHelper
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")
diff --git a/app/models/course.rb b/app/models/course.rb
index 4d0fe8378..276cc7652 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -1,11 +1,11 @@
class Course < ActiveRecord::Base
include Redmine::SafeAttributes
- attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state
- belongs_to :project, :class_name => 'Project', :foreign_key => :extra
+ 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
+ validates_presence_of :state, :term
safe_attributes 'extra',
'time',
'name',
@@ -13,7 +13,8 @@ class Course < ActiveRecord::Base
'code',
'location',
'tea_id',
- 'state'
+ 'state',
+ 'term'
end
diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb
index bc16f5358..5dae9e940 100644
--- a/app/views/bids/_homework.html.erb
+++ b/app/views/bids/_homework.html.erb
@@ -8,9 +8,13 @@
<%= submit_tag l(:button_create) %>
<% end %>
+<% 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), 'put-bid-form' %>
+<% elsif @homework_list.empty? %>
+
+<% end %>
<%= render :partial => 'homework_list', :locals => {:homework => @homework_list} %>
diff --git a/app/views/bids/_project_list.html.erb b/app/views/bids/_project_list.html.erb
index a852a07b5..bb75bbf6b 100644
--- a/app/views/bids/_project_list.html.erb
+++ b/app/views/bids/_project_list.html.erb
@@ -5,9 +5,12 @@
<%= 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 %>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index b769dc9ac..18bd3af7e 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -35,7 +35,7 @@
<%= link_to image_tag(url_to_avatar(@project), :class => 'avatar2') %> |
- <%= textilizable @project.name %>
+ <%= @project.name %>
<%= join_in_course(@project, User.current)%>
|
@@ -57,7 +57,7 @@
<%=link_to files_count, project_files_path(@project) %> |
- <%= " 成员" %> |
+ <%= "成员" %> |
<%= l(:label_course_data) %> |
@@ -67,17 +67,19 @@
-
+
- 主讲老师: |
+ 主讲老师: |
-
- 教师单位: |
+ 课程学期: |
+
+
+ 教师单位: |
diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb
index 2b7fa7552..a20f4e6f4 100644
--- a/app/views/layouts/base_homework.html.erb
+++ b/app/views/layouts/base_homework.html.erb
@@ -19,63 +19,51 @@
-
- <%=render :partial => 'layouts/base_header'%>
-
+
+ <%= render :partial => 'layouts/base_header'%>
+