parent
165dbc3f78
commit
ae8fcca14f
|
@ -86,6 +86,35 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def member
|
||||
## 有角色参数的才是课程,没有的就是项目
|
||||
@render_file = 'member_list'
|
||||
@teachers= searchTeacherAndAssistant(@course)
|
||||
@canShowCode = isCourseTeacher(User.current.id)
|
||||
case params[:role]
|
||||
when '1'
|
||||
@subPage_title = l :label_teacher_list
|
||||
@members = searchTeacherAndAssistant(@course)
|
||||
when '2'
|
||||
@subPage_title = l :label_student_list
|
||||
@members = searchStudent(@course)
|
||||
else
|
||||
@subPage_title = ''
|
||||
@members = @course.member_principals.includes(:roles, :principal).all.sort
|
||||
end
|
||||
@members = paginateHelper @members
|
||||
render :layout => 'base_courses'
|
||||
end
|
||||
|
||||
#判断指定用户是否为课程教师
|
||||
def isCourseTeacher(id)
|
||||
result = false
|
||||
if @teachers.find_by_user_id(id) != nil
|
||||
result = true
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def handle_course courses, activities
|
||||
course_activity_count_array=activities.values()
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ class Principal < ActiveRecord::Base
|
|||
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
||||
has_many :coursememberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :course, :roles ], :conditions => "#{Course.table_name}.status<>#{Course::STATUS_ARCHIVED}", :order => "#{Course.table_name}.name"
|
||||
has_many :projects, :through => :memberships
|
||||
#add by nwb
|
||||
has_many :courses, :through => :coursememberships
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
|
||||
# Groups and active users
|
||||
|
|
|
@ -100,7 +100,7 @@ class User < Principal
|
|||
has_many :journal_replies, :dependent => :destroy
|
||||
has_many :activities, :dependent => :destroy
|
||||
has_many :students_for_courses
|
||||
has_many :courses, :through => :students_for_courses, :source => :project
|
||||
#has_many :courses, :through => :students_for_courses, :source => :project
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'"
|
||||
####
|
||||
|
@ -690,6 +690,10 @@ class User < Principal
|
|||
projects.to_a.include?(project)
|
||||
end
|
||||
|
||||
def member_of_course?(course)
|
||||
courses.to_a.include?(course)
|
||||
end
|
||||
|
||||
# Returns a hash of user's projects grouped by roles
|
||||
def projects_by_role
|
||||
return @projects_by_role if @projects_by_role
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<% if members.any? %>
|
||||
<% members.each do |member| %>
|
||||
<div class="well">
|
||||
<% next if member.new_record? %>
|
||||
<% unless member.created_on.nil? %>
|
||||
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||
<% end %>
|
||||
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
|
||||
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||
<!--teacher's code disapeared moified by huang-->
|
||||
|
||||
<% unless member.user.user_extensions.identity ==0 %>
|
||||
<!-- added by bai 加学号 -->
|
||||
<%if @canShowCode%>
|
||||
<%= content_tag "p", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :class => "nomargin avatar_name" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class ="clear avatar_name">
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
|
||||
</div>
|
||||
<% end; reset_cycle %>
|
||||
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
||||
<% else %>
|
||||
<p class="nodata">
|
||||
<%= l(:label_no_data) %>
|
||||
</p>
|
||||
<% end %>
|
|
@ -0,0 +1,10 @@
|
|||
<div class="member_header">
|
||||
<p>
|
||||
<%= @subPage_title %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="member_content">
|
||||
<%= error_messages_for 'member' %>
|
||||
<%= render :partial => @render_file, :locals => {:members => @members} %>
|
||||
</div>
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
<%= join_in_course(@course, User.current) %>
|
||||
<% end %>
|
||||
<% unless User.current.member_of?(@course) %>
|
||||
<% unless User.current.member_of_course?(@course) %>
|
||||
<!-- <%= image_tag "/images/fav.png" %> -->
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -99,14 +99,14 @@
|
|||
|
||||
<td class="font_index">
|
||||
<!-- 1 教师; 2 学生;0 全部-->
|
||||
<% if User.current.member_of?(@course) %>
|
||||
<% if User.current.member_of_course?(@course) %>
|
||||
<%= link_to "#{teacherCount(@course)}", course_member_path(@course, :role => 1), :course => '1' %>
|
||||
<% else %>
|
||||
<span><%= teacherCount(@course)%></span> <!--<%= link_to "#{teacherCount(@course)}", "javascript:void(0)", :course => '1' %>-->
|
||||
<% end%>
|
||||
</td>
|
||||
<td class="font_index">
|
||||
<% if User.current.member_of?(@course) %>
|
||||
<% if User.current.member_of_course?(@course) %>
|
||||
<%= link_to "#{studentCount(@course)}", course_member_path(@course, :role => 2), :course => '1' %>
|
||||
<% else %>
|
||||
<span><%= studentCount(@course)%></span>
|
||||
|
|
|
@ -551,9 +551,11 @@ RedmineApp::Application.routes.draw do
|
|||
get 'homework', :action => 'homework', :as => 'homework'
|
||||
get 'new_homework', :action => 'new_homework', :as => 'new_homework'
|
||||
get 'file', :action => 'file', :as => 'file'
|
||||
get 'member', :controller => 'courses', :action => 'member', :as => 'member'
|
||||
post 'finishcourse'
|
||||
post 'restartcourse'
|
||||
end
|
||||
match '/member', :controller => 'courses', :action => 'member', :as => 'member', :via => :get
|
||||
resources :boards
|
||||
resources :files, :only => [:index, :new, :create] do
|
||||
collection do
|
||||
|
|
Loading…
Reference in New Issue