parent
3d12d6f0e8
commit
9765f11f7e
|
@ -78,7 +78,21 @@ class CoursesController < ApplicationController
|
||||||
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def join_group
|
||||||
|
group = CourseGroup.find(params[:object_id])
|
||||||
|
member = Member.find(:conditions => {:course_id => @course.id, :user_id => User.current.id}).first
|
||||||
|
member.course_group_id = group.id
|
||||||
|
member.save
|
||||||
|
end
|
||||||
|
def unjoin_group
|
||||||
|
member = Member.find(:conditions => {:course_group_id => params[object_id], :user_id => User.current.id}).first
|
||||||
|
member.course_group_id = 0
|
||||||
|
member.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_join_group
|
||||||
|
|
||||||
|
end
|
||||||
def join_private_courses
|
def join_private_courses
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
@ -198,7 +212,7 @@ class CoursesController < ApplicationController
|
||||||
|
|
||||||
def searchmembers
|
def searchmembers
|
||||||
@render_file = 'member_list'
|
@render_file = 'member_list'
|
||||||
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
q = "#{params[:name].strip}"
|
q = "#{params[:name].strip}"
|
||||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||||
|
@ -208,15 +222,36 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def addgroups
|
def addgroups
|
||||||
|
if params[:group_name]
|
||||||
|
group = CourseGroup.new
|
||||||
|
group.name = params[:group_name]
|
||||||
|
group.course_id = @course.id
|
||||||
|
group.save
|
||||||
|
end
|
||||||
|
@course_groups = @course.course_groups
|
||||||
end
|
end
|
||||||
|
|
||||||
def updategroupname
|
def updategroupname
|
||||||
|
if params[:group_name]
|
||||||
|
group = CourseGroup.find(params[:group_id])
|
||||||
|
group.name = params[:group_name]
|
||||||
|
group.save
|
||||||
|
end
|
||||||
|
@course_groups = @course.course_groups
|
||||||
end
|
end
|
||||||
|
|
||||||
def searchgroupmembers
|
def searchgroupmembers
|
||||||
|
@render_file = 'member_list'
|
||||||
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||||
|
@is_remote = true
|
||||||
|
if params[:group_id] && params[:group_id] != "0"
|
||||||
|
@group = CourseGroup.find(params[:group_id])
|
||||||
|
@results = searchStudent_by_group(@group)
|
||||||
|
else
|
||||||
|
@results = searchStudent(@course)
|
||||||
|
end
|
||||||
|
|
||||||
|
@results = paginateHelper @results
|
||||||
end
|
end
|
||||||
def member
|
def member
|
||||||
## 有角色参数的才是课程,没有的就是项目
|
## 有角色参数的才是课程,没有的就是项目
|
||||||
|
|
|
@ -199,6 +199,14 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
members
|
members
|
||||||
end
|
end
|
||||||
|
def searchStudent_by_group group
|
||||||
|
#searchPeopleByRoles(project, StudentRoles)
|
||||||
|
members = []
|
||||||
|
group.members.each do |m|
|
||||||
|
members << m if m && m.user && m.user.allowed_to?(:as_student,project)
|
||||||
|
end
|
||||||
|
members
|
||||||
|
end
|
||||||
# =====================================================================================
|
# =====================================================================================
|
||||||
|
|
||||||
#def searchCountByRoles project, roles_id
|
#def searchCountByRoles project, roles_id
|
||||||
|
|
|
@ -109,6 +109,28 @@ module WatchersHelper
|
||||||
link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options
|
link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def join_in_course_group(coursegroups,group, user, options=[])
|
||||||
|
return '' unless user && user.logged?
|
||||||
|
|
||||||
|
@isjoin = false
|
||||||
|
coursegroups.each do |g|
|
||||||
|
@isjoin = user.member_of_course_group?(g)
|
||||||
|
end
|
||||||
|
url_t = join_group_path(:object_id => group.id)
|
||||||
|
url_f = try_join_group_path(:object_id => group.id)
|
||||||
|
if @isjoin == true
|
||||||
|
joined = user.member_of_course_group?(group)
|
||||||
|
text = l(:label_exit_course)
|
||||||
|
|
||||||
|
if joined
|
||||||
|
link_to text, url_t, :remote => true, :method => 'delete', :id => "#{group.id}", :confirm => l(:text_are_you_sure_out), :class => []+options
|
||||||
|
|
||||||
|
end
|
||||||
|
else
|
||||||
|
text = l(:label_new_join)
|
||||||
|
link_to text, url_f, :remote => true, :method => 'post', :id => "#{group.id}", :class => []+options
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# 用户是否允许加入课程判断
|
# 用户是否允许加入课程判断
|
||||||
# add by nwb
|
# add by nwb
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
class CourseGroup < ActiveRecord::Base
|
class CourseGroup < ActiveRecord::Base
|
||||||
# attr_accessible :title, :body
|
# attr_accessible :title, :body
|
||||||
belongs_to :course
|
belongs_to :course
|
||||||
has_many :members
|
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
|
||||||
|
has_many :memberships, :class_name => 'Member'
|
||||||
|
has_many :member_principals, :class_name => 'Member',
|
||||||
|
:include => :principal,
|
||||||
|
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||||
|
has_many :principals, :through => :member_principals, :source => :principal
|
||||||
|
has_many :users, :through => :members
|
||||||
|
|
||||||
before_destroy :set_member_nil
|
before_destroy :set_member_nil
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Principal < ActiveRecord::Base
|
||||||
has_many :projects, :through => :memberships
|
has_many :projects, :through => :memberships
|
||||||
#add by nwb
|
#add by nwb
|
||||||
has_many :courses, :through => :coursememberships
|
has_many :courses, :through => :coursememberships
|
||||||
|
has_many :course_groups, :through => :coursememberships
|
||||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||||
|
|
||||||
# Groups and active users
|
# Groups and active users
|
||||||
|
|
|
@ -690,6 +690,9 @@ class User < Principal
|
||||||
courses.to_a.include?(course)
|
courses.to_a.include?(course)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def member_of_course_group?(course_group)
|
||||||
|
course_groups.to_a.include?(course_group)
|
||||||
|
end
|
||||||
# Returns a hash of user's projects grouped by roles
|
# Returns a hash of user's projects grouped by roles
|
||||||
def projects_by_role
|
def projects_by_role
|
||||||
return @projects_by_role if @projects_by_role
|
return @projects_by_role if @projects_by_role
|
||||||
|
|
|
@ -1,51 +1,59 @@
|
||||||
<script type="application/javascript">
|
|
||||||
function asign_id(id) {
|
|
||||||
document.getElementById(id).value = id;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<%# if course_groups.any? %>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
<li style=" color:#8b8b8b;">分班:</li>
|
<li style=" color:#8b8b8b;">分班:</li>
|
||||||
<% form_tag(searchgroupmembers_course_path(@course), :method => 'get', :remote => true) do %>
|
|
||||||
<li class="classbox">
|
|
||||||
<%= hidden_field 'all', params[:group_id], name: 'all' %>
|
|
||||||
<%= submit_tag l:(label_all), :onclick => "asign_id('all')" %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
<li id="show_groups" class="classbox">
|
|
||||||
|
|
||||||
|
<li class="classbox">
|
||||||
|
<%= form_tag( searchgroupmembers_course_path(@course, :group_id => 0), method: 'get',:remote=>true) do %>
|
||||||
|
|
||||||
|
|
||||||
|
<%= hidden_field_tag "all", params[:group_id], name: 'all' %>
|
||||||
|
<%= submit_tag l(:label_all), :style => "background: #f8df8c; border:0px; color: black" %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
<% if course_groups.any? %>
|
||||||
<% course_groups.each do |group| %>
|
<% course_groups.each do |group| %>
|
||||||
<li class="classbox" id="group_name_<%= group.id %>">
|
<li class="classbox" id="group_name_<%= group.id %>">
|
||||||
<% form_tag(searchgroupmembers_course_path(@course), :method => 'get', :remote => true) do %>
|
<%= form_tag(searchgroupmembers_course_path(@course,:group_id => group.id), method: 'get', remote: true) do %>
|
||||||
<%= hidden_field group, :id, :value => params[:group_id] %>
|
<%#= text_field_tag "group_id", params[:group_id] %>
|
||||||
<%= submit_tag l:(label_all), :onclick => "asign_id(#{group.id})" %>
|
<%= submit_tag group.name, :onclick => "$asign_id(#{group.id})",:style => "background: #f8df8c; border:0px; color: black; float:left;"%>
|
||||||
|
<% if @canShowCode %>
|
||||||
|
<a href="javascript:void(0)" class="f_l" onclick="$('#add_tag_<%= group.id %>').slideToggle();"><img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" /></a>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="javascript:void(0)" class="f_l" onclick="$('#add_tag_<%= group.id %>').slideToggle();"><img src="images/pic_edit.png" width="14" height="15" alt="编辑班级" /></a>
|
</li>
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<% form_tag(updategroupname_course_path(@course), :method => 'get', :remote => true, :update => 'group_name') do %>
|
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, update: 'group_name') do %>
|
||||||
<span id="add_tag_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
|
<span id="add_tag_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
|
||||||
<%= text_field group, :value => params[:group_name], :size=>"20", :class=>"isTxt w90 f_l", :style=>"padding: 0px", :max => 100 %>
|
<%= text_field_tag "group_name", params[:group_name], :size=>10, :class=>"isTxt w90 f_l", :style=>"padding: 0px", :max => 100 %>
|
||||||
<!--<input type="button" class="submit f_l" onclick="addTag();" style="width: 43px"/>-->
|
<!--<input type="button" class="submit f_l" onclick="addTag();" style="width: 43px"/>-->
|
||||||
<%= submit_tag group.name, :class => "submit f_1", :style => "width: 43px;", :update => "group_name_#{group.id}" %>
|
<%= submit_tag '', class: "submit f_l", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<li style="margin-left:15px;">
|
<li style="margin-left:15px;">
|
||||||
<a href="javascript:void(0)" class="st_add f_l" onclick="$('#add_tag04').slideToggle();">+添加分班</a>
|
<a href="javascript:void(0)" class="st_add f_l" onclick="$('#add_tag04').slideToggle();">+添加分班</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span id="add_tag04" style="display:none; vertical-align: middle;" class="ml10 f_l">
|
<span id="add_tag04" style="display:none; vertical-align: middle;" class="ml10 f_l">
|
||||||
<input type="text" id="" name="" size="20" class="isTxt w90 f_l" style="padding: 0px" maxlength="100" />
|
<%= form_tag( addgroups_course_path(@course), method: 'get',:remote=>true) do %>
|
||||||
<input type="button" class="submit f_l" onclick="addTag();" style="width: 43px"/>
|
|
||||||
<input type="button" class="submit_2" onclick="$('#add_tag04').slideToggle();" style="width: 43px"/>
|
<%= text_field_tag "group_name", params[:group_name], size: "20", class: "isTxt w90 f_l", style: "padding: 0px", maxlength: "100" %>
|
||||||
</span>
|
<%= submit_tag '', class: "submit f_l", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
|
||||||
|
<%= link_to_function '', "$('#add_tag04').slideToggle();", class: "submit_2", style: "width: 43px"%>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<span class="f_l"><%= @group %><%= @subPage_title %></span>
|
||||||
|
<% if !@canShowCode %>
|
||||||
|
<%= join_in_course_group(@course.course_groups,@group, User.current) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%# end %>
|
|
|
@ -0,0 +1 @@
|
||||||
|
$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>");
|
|
@ -12,13 +12,14 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<%# if @canShowCode %>
|
|
||||||
<div class="st_addclass">
|
<div class="st_addclass" id = "st_groups">
|
||||||
<%= render :partial => 'groups_name', locals: {:course_groups => @course_groups} %>
|
<%= render :partial => 'groups_name', locals: {:course_groups => @course_groups} %>
|
||||||
</div>
|
</div>
|
||||||
<%# end %>
|
|
||||||
|
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<div class="member_content" id = "member_content">
|
<div class="member_content" id = "member_content">
|
||||||
<%= error_messages_for 'member' %>
|
<%= error_messages_for 'member' %>
|
||||||
<%= render :partial => @render_file, :locals => {:members => @members} %>
|
<%= render :partial => @render_file, :locals => {:members => @members} %>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* Created by Administrator on 2014/12/3.
|
||||||
|
*/
|
||||||
|
$("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>");
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* Created by Administrator on 2014/12/3.
|
||||||
|
*/
|
||||||
|
$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>");
|
|
@ -1120,6 +1120,7 @@ zh:
|
||||||
text_workflow_edit: 选择角色和跟踪标签来编辑工作流程
|
text_workflow_edit: 选择角色和跟踪标签来编辑工作流程
|
||||||
text_are_you_sure: 您确定要删除吗?
|
text_are_you_sure: 您确定要删除吗?
|
||||||
text_are_you_sure_out: 你确定要退出该课程吗?
|
text_are_you_sure_out: 你确定要退出该课程吗?
|
||||||
|
text_are_you_sure_out_group: 你确定要退出该分组吗?
|
||||||
text_journal_changed: "%{label} 从 %{old} 变更为 %{new}"
|
text_journal_changed: "%{label} 从 %{old} 变更为 %{new}"
|
||||||
text_journal_set_to: "%{label} 被设置为 %{value}"
|
text_journal_set_to: "%{label} 被设置为 %{value}"
|
||||||
text_journal_deleted: "%{label} 已删除 (%{old})"
|
text_journal_deleted: "%{label} 已删除 (%{old})"
|
||||||
|
|
|
@ -644,7 +644,9 @@ RedmineApp::Application.routes.draw do
|
||||||
post 'finishcourse'
|
post 'finishcourse'
|
||||||
post 'restartcourse'
|
post 'restartcourse'
|
||||||
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
|
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
|
||||||
|
match "searchgroupmembers", :via => [:post, :get]
|
||||||
|
match "updategroupname", :via => [:post, :get]
|
||||||
|
match "addgroups", :via => [:post, :get]
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
match 'join_private_courses', :via => [:get, :post]
|
match 'join_private_courses', :via => [:get, :post]
|
||||||
|
@ -741,6 +743,8 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
post 'join_in/join', :to => 'courses#join', :as => 'join'
|
post 'join_in/join', :to => 'courses#join', :as => 'join'
|
||||||
delete 'join_in/join', :to => 'courses#unjoin'
|
delete 'join_in/join', :to => 'courses#unjoin'
|
||||||
|
post 'join_in/join_group', :to => 'courses#join_group', :as => 'join_group'
|
||||||
|
delete 'join_in/join_group', :to => 'courses#unjoin_group'
|
||||||
post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest'
|
post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest'
|
||||||
delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest'
|
delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest'
|
||||||
match 'calls/:id/show_participator', :to => 'bids#show_participator' # bai
|
match 'calls/:id/show_participator', :to => 'bids#show_participator' # bai
|
||||||
|
@ -749,6 +753,7 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
delete 'attachment/:id', :to => 'attachments#delete_homework'
|
delete 'attachment/:id', :to => 'attachments#delete_homework'
|
||||||
match 'new_join', :to => 'courses#new_join', :as => 'try_join'
|
match 'new_join', :to => 'courses#new_join', :as => 'try_join'
|
||||||
|
match 'new_join_group', :to => 'courses#new_join_group', :as => 'try_join_group'
|
||||||
match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest'
|
match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest'
|
||||||
match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post
|
match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post
|
||||||
match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post]
|
match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post]
|
||||||
|
|
Loading…
Reference in New Issue