用户看别人课程主页时显示问题

This commit is contained in:
huangjingquan 2013-10-10 21:33:52 +08:00
parent 8703709bd0
commit e25425d9a7
5 changed files with 67 additions and 34 deletions

View File

@ -78,7 +78,7 @@ class UsersController < ApplicationController
##added by fq
def watch_bids
@bids = Bid.watched_by(@user)
@bids = Bid.visible.where('reward_type = ?', 1)
@bids = Bid.visible.where('reward_type = ?', 1) # modified by huang
@offset, @limit = api_offset_and_limit({:limit => 10})
@bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']

View File

@ -94,6 +94,35 @@ module UsersHelper
def user_course(state)
content = ''.html_safe
if @user != User.current
if @user.user_extensions.identity == 0
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}))
content_tag('div', content, :class => "pagination")
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")
content_tag('div', content, :class => "pagination")
end
else
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}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '他的作业', :class => "current-page")
content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
end
else
if @user.user_extensions.identity == 0
case state
when 0
@ -106,20 +135,21 @@ module UsersHelper
content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
else
case state
when 0
s = content_tag('span', l(:label_my_course), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '我的作业', :class => "current-page")
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
end
else
case state
when 0
s = content_tag('span', l(:label_my_course), :class => "current-page")
content << content_tag('li', s)
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination")
when 1
s = content_tag('span', '我的作业', :class => "current-page")
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination")
end
end
end
end

View File

@ -47,9 +47,9 @@
<table border="0">
<tr>
<td align="cneter">
<%= text_field_tag 'course_password', nil, :size => 27 %></td>
</td>
<%= text_field_tag 'course_password', nil, :size => 48%>
<%= text_field_tag 'course_password', nil, :size => 45 %>
<p class="buttons" style="padding-top: 10px; padding-bottom: 1px; margin-bottom: 1px">
<%= submit_tag l(:label_new_join), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %>

View File

@ -1,5 +1,5 @@
<div class="content_frame">
<% if @memberships.empty? %>
<% if @memberships.empty? %>
<% if @user != User.current %>
<p class="font_description">
<%= l(:label_project_course_un) %>
@ -7,16 +7,20 @@
<% else %>
<p class="font_description">
<% if @user.user_extensions.identity == 0 %>
<!--teacher could create the course directly-->
<%= l(:label_project_course_unadd) %><%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %>
<% else %>
<!--joined the list of the courstlist-->
<%= l(:label_project_cousre_studentun) %><%= link_to"#{l(:label_course_join_student)}",{:controller=>'projects',:action=>'course', :course => 1}, :class => 'icon icon-add' %>
<% end %>
</p>
<% end %>
<% else %>
<% else %>
<% unless @user != User.current %>
<% if @user.user_extensions.identity == 0 %>
<%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %>
<% end %>
<% end %>
<ul class="user_project_sort">
<% for membership in @memberships %>

View File

@ -1,20 +1,19 @@
<!-- added by fq -->
<!--huang-->
<%= user_course @state%>
<% if @state == 0 %>
<% if @user.user_extensions.identity == 0 %>
<%= render :partial => 'my_course' %>
<% else %>
<%= render :partial => 'my_joinedcourse' %>
<% end %>
<% if @user.user_extensions.identity == 0 %> <!-- for teacher-->
<%= render :partial => 'my_course' %>
<% else %> <!--for student-->
<%= render :partial => 'my_joinedcourse' %>
<% end %>
<% elsif @state == 1 %>
<% if @user.user_extensions.identity == 0 %>
<%= render :partial => 'my_create_homework' %>
<% else %>
<%= render :partial => 'my_homework' %>
<% end %>
<% if @user.user_extensions.identity == 0 %>
<%= render :partial => 'my_create_homework' %>
<% else %>
<%= render :partial => 'my_homework' %>
<% end %>
<% else @state == 2 %>
<%= render :partial => 'my_joinedcourse' %>
<%= render :partial => 'my_joinedcourse' %>
<% end %>