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 @@
- +
- + - - + + + +
主讲老师:<%=@course.teacher.lastname+@course.teacher.firstname %>主讲老师:<%= @course.teacher.lastname+@course.teacher.firstname %>
教师单位:PDL(未定)课程学期:<%= @course.term %>
教师单位:<%= @course.teacher.user_extensions.occupation %>
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'%> +
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 043baec3e..aa931b7af 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -89,10 +89,10 @@
- + - + 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;" %>

<%= render :partial => 'attachments/form', :locals => {:container => @news} %>

diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 7e6fbd546..cded25576 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -14,7 +14,11 @@ @@ -53,7 +56,7 @@
<%= l(:label_user_joinin) %><%= format_date(@user.created_on) %><%= l(:label_user_joinin) %><%= format_time(@user.created_on) %>
<%= l(:label_user_login) %><%= format_date(@user.last_login_on) %><%= l(:label_user_login) %><%= format_time(@user.last_login_on) %>
<%= l(:label_user_mail) %><%= mail_to(h(@user.mail), nil, :encode => 'javascript') %> <%= link_to_user member.principal %> - <% if @project.project_type == 1 %> + <% if @project.project_type == 1 %> <% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %> Teacher @@ -65,9 +68,19 @@ <% end %> - <% else%> - <%=h member.roles.sort.collect(&:to_s).join(', ') %> - <% 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), diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index c735859bb..4f9554e42 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -1,42 +1,56 @@
-<% unless @memberships.empty? %> -
    - <% for membership in @memberships %> -
  • - - - - - - -
    <%= link_to image_tag(url_to_avatar(membership.project), :class => 'avatar'), project_path(membership.project) %> - - - - - - - - - - - -
    <%= link_to_user(membership.user) if membership.respond_to?(:user) %> - <%= l(:label_create_project) %> <%= link_to_project(membership.project) %>
    -

    - <%= 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 %> + <% unless @memberships.empty? %> +
    + <% for membership in @memberships %> +
  • + + + + + -<% end %> -<%= call_hook :view_account_left_bottom, :user => @user %> +
    <%= 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} %>) + <%= l(:label_member)%>(<%= link_to (membership.project.members.count) %>)
    +

    + <%= 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_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/_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/user_courses.html.erb b/app/views/users/user_courses.html.erb index 8124468da..409a38acd 100644 --- a/app/views/users/user_courses.html.erb +++ b/app/views/users/user_courses.html.erb @@ -1,10 +1,11 @@ <%= user_course @state%> - -<% if @state == 0%> +<% if @state == 0 %> <%= render :partial => 'my_course' %> -<% else %> +<% elsif @state == 1 %> <%= render :partial => 'my_homework' %> +<% else @state == 2 %> +<%= render :partial => 'my_notice' %> <% end %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 33485a182..e4dd8d83f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -222,6 +222,7 @@ zh: field_couurse_time: 学时 field_course_code: 学分 field_state: 加入课程口令 + field_term: 学期 #end field_description: 描述 field_summary: 摘要 @@ -521,6 +522,10 @@ zh: label_user_login_tips: 您还没有登录,请登录后留言 #end #by huang + label_term: 学期 + label_spring: 春季 + label_summer: 夏季 + label_autumn: 秋季 label_followers: 关注 label_teacher: 教师 label_limit_time: 截止日期 @@ -579,6 +584,7 @@ zh: label_report_plural: 报表 label_news: 新闻 label_news_new: 添加新闻 + bale_news_notice: 添加通知 #huang label_news_notice: 发布课程通知 label_news_plural: 新闻 label_news_latest: 最近的新闻 @@ -586,8 +592,9 @@ zh: label_news_added: 新闻已添加 label_settings: 配置 label_overview: 课程动态 - label_question_student: 学生提问 #huang + label_question_student: 学生反馈 #huang label_homework_commit: 提交作业 #huang + label_homework_info: 作业情况 #huang label_course_file: 资料下载 label_course_news: 课程通知 label_version: 版本 @@ -1271,6 +1278,7 @@ zh: label_wrong_date: 时间格式错误,请输入正确的时间 yyyy-mm-dd label_bidding_succeed: 应标成功 label_bidding_fail: 应标失败,该项目已经应标 + label_bidding_homework_fail: 作业提交失败,该作业已经被提交! label_requirement_list: 需求列表 @@ -1282,7 +1290,7 @@ zh: label_x_homework_project: #modify by huang zero: 已提交的作业 one: 已提交的作业 - other: 已提交的uzoye + other: 已提交的作业 #end label_x_responses: #modify by men zero: 留言 @@ -1476,7 +1484,8 @@ zh: label_user_create_project: 创建了 #added by bai label_identity: 身份 - label_teacher: 教 师 + label_teacher: 教 师 + label_teacher_homework: 教师姓名 label_student: 学生 label_other: 其他 label_gender: 性别 @@ -1497,4 +1506,4 @@ zh: label_course_homework_list: 作业列表 label_course_homework_new: 发布作业 label_course_data: 资料 - label_homework_statistics: 作业统计 \ No newline at end of file + label_homework_statistics: 作业统计 diff --git a/db/migrate/20130917123036_add_term_to_courses.rb b/db/migrate/20130917123036_add_term_to_courses.rb new file mode 100644 index 000000000..3f7f7ef30 --- /dev/null +++ b/db/migrate/20130917123036_add_term_to_courses.rb @@ -0,0 +1,6 @@ +class AddTermToCourses < ActiveRecord::Migration + def change + add_column :courses, :term, :string + add_column :courses, :string, :string + end +end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 553bc6190..aa92bb6bc 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -230,11 +230,15 @@ ul.tool li{list-style-type:none; font-size:12px; font-family:微软雅黑; } +.justify_side > span{ + text-align: justify; + width: 180px; +} .font_lighter_sidebar{ /*font-family:微软雅黑;*/ color:#919294; font-size:13px; - padding-left: 12px; + padding-left: 0px; padding-right: 8px; line-height: 1.5em; }