Merge branch 'szzh' into develop

This commit is contained in:
sw 2014-12-06 13:48:19 +08:00
commit af7de6e61c
9 changed files with 69 additions and 53 deletions

View File

@ -199,6 +199,7 @@ class CoursesController < ApplicationController
end end
def searchmembers def searchmembers
@subPage_title = l :label_student_list
@render_file = 'member_list' @render_file = 'member_list'
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true @is_remote = true
@ -211,6 +212,7 @@ class CoursesController < ApplicationController
end end
def addgroups def addgroups
@subPage_title = l :label_student_list
if params[:group_name] if params[:group_name]
group = CourseGroup.new group = CourseGroup.new
group.name = params[:group_name] group.name = params[:group_name]
@ -225,6 +227,7 @@ class CoursesController < ApplicationController
end end
def updategroupname def updategroupname
@subPage_title = l :label_student_list
if params[:group_name] if params[:group_name]
group = CourseGroup.find(params[:group_id]) group = CourseGroup.find(params[:group_id])
group.name = params[:group_name] group.name = params[:group_name]
@ -237,6 +240,7 @@ class CoursesController < ApplicationController
@course_groups = @course.course_groups @course_groups = @course.course_groups
end end
def join_group def join_group
@subPage_title = l :label_student_list
group = CourseGroup.find(params[:object_id]) group = CourseGroup.find(params[:object_id])
member = Member.where(:course_id => @course.id, :user_id => User.current.id).first member = Member.where(:course_id => @course.id, :user_id => User.current.id).first
member.course_group_id = group.id member.course_group_id = group.id
@ -248,6 +252,7 @@ class CoursesController < ApplicationController
search_group_members group search_group_members group
end end
def unjoin_group def unjoin_group
@subPage_title = l :label_student_list
group = CourseGroup.find(params[:object_id]) group = CourseGroup.find(params[:object_id])
member = Member.where(:course_id => @course.id, :user_id => User.current.id).first member = Member.where(:course_id => @course.id, :user_id => User.current.id).first
member.course_group_id = 0 member.course_group_id = 0
@ -259,6 +264,7 @@ class CoursesController < ApplicationController
search_group_members group search_group_members group
end end
def searchgroupmembers def searchgroupmembers
@subPage_title = l :label_student_list
@render_file = 'member_list' @render_file = 'member_list'
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true @is_remote = true
@ -273,6 +279,7 @@ class CoursesController < ApplicationController
@results = paginateHelper @results @results = paginateHelper @results
end end
def search_group_members group def search_group_members group
@subPage_title = l :label_student_list
@render_file = 'member_list' @render_file = 'member_list'
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true @is_remote = true
@ -290,6 +297,7 @@ class CoursesController < ApplicationController
@role = params[:role] @role = params[:role]
@course_groups = @course.course_groups if @course.course_groups @course_groups = @course.course_groups if @course.course_groups
@course_group_id = params[:@course_group_id] unless params[:@course_group_id].nil? @course_group_id = params[:@course_group_id] unless params[:@course_group_id].nil?
@show_serch = params[:role] == '2'
case params[:role] case params[:role]
when '1' when '1'
@subPage_title = l :label_teacher_list @subPage_title = l :label_teacher_list

View File

@ -217,6 +217,7 @@ class MembersController < ApplicationController
joined.each do |join| joined.each do |join|
join.delete join.delete
end end
@member.course_group_id = 0
end end
if role.allowed_to?(:is_manager) if role.allowed_to?(:is_manager)
@courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id) @courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id)

View File

@ -123,17 +123,17 @@ module WatchersHelper
url_f = join_group_path(:object_id => group.id) url_f = join_group_path(:object_id => group.id)
if @isjoin == true if @isjoin == true
joined = user.member_of_course_group?(group) joined = user.member_of_course_group?(group)
text = l(:label_exit_course) text = l(:label_exit_group)
if joined if joined
link_to text, {:controller => "courses", :action => "join_group", :object_id => "#{group.id}"}, link_to text, {:controller => "courses", :action => "join_group", :object_id => "#{group.id}"},
:remote => true, :method => 'delete', :remote => true, :method => 'delete',
:id => "#{group.id}", :style => "padding: 8px 8px 4px;", :id => "#{group.id}", :style => "padding: 8px 8px 4px; ",
:confirm => l(:text_are_you_sure_out_group), :class => 'group_in' :confirm => l(:text_are_you_sure_out_group), :class => 'group_in'
end end
else else
text = l(:label_new_join) text = l(:label_new_join_group)
form_tag({:controller => "courses", :action => "join_group", :object_id => "#{group.id}"}, :remote => true, :method => 'post') do form_tag({:controller => "courses", :action => "join_group", :object_id => "#{group.id}"}, :remote => true, :method => 'post') do
submit_tag text, class: "group_in", style: "width: 43px;height: 21px;" submit_tag text, class: "group_in", style: "width: 43px;height: 21px;"
end end

View File

@ -26,11 +26,11 @@ class Principal < ActiveRecord::Base
has_many :members, :foreign_key => 'user_id', :dependent => :destroy has_many :members, :foreign_key => 'user_id', :dependent => :destroy
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 :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 ], :order => "#{Course.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 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 :course_groups, :through => :members
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

View File

@ -5,9 +5,21 @@
alert('<%= l(:label_limit_groupname) %>'); alert('<%= l(:label_limit_groupname) %>');
} }
} }
function validate_groupname_null(value1) { function checkclass(value) {
if(value1.length == 0) { for(var i = 0; i < document.getElementsByName("check_group_name").length; i++) {
if(document.getElementsByName("check_group_name")[i].id == value) {
document.getElementById(value).className = "selected";
}
else {
document.getElementsByName("check_group_name")[i].className = "classbox";
}
}
}
function validate_groupname_null(value1) {
value1 = value1.trim();
if(value1.length == 0 ) {
alert('<%= l(:label_limit_groupname_null) %>'); alert('<%= l(:label_limit_groupname_null) %>');
} }
} }
@ -16,41 +28,30 @@
validate_groupname(value1); validate_groupname(value1);
} }
function validate_add_group() { function validate_add_group() {
value1 = document.getElementById('group_name').value; value1 = document.getElementById('group_name').value;
validate_groupname(value1); validate_groupname(value1);
validate_groupname_null(value1); validate_groupname_null(value1);
} }
</script> </script>
<ul> <ul>
<li class="classbox" id = "group_name_0" name="check_group_name">
<li style=" color:#8b8b8b;">分班:</li> <% course_member_count = l(:label_all) + " ( " + @membercount.to_s + "人)" %>
<%= link_to course_member_count, searchgroupmembers_course_path(@course,:group_id => 0), :onclick => "checkclass('group_name_0')", method: 'get', remote: true,:style => " border:0px; color: #0d90c3; float:left;"%>
<li class="classbox">
<% course_member_count = l(:label_all) + "(" + @membercount.to_s + "人)" %>
<%= 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 course_member_count, :style => "background: #f8df8c; border:0px; color: black" %>
<% end %>
</li> </li>
<% if course_groups.any? %> <% if course_groups.any? %>
<% course_groups.each do |group| %> <% course_groups.each do |group| %>
<% group_display = group.name + "(" + group.members.count.to_s + "人)" %> <% group_display = group.name + " ( " + group.members.count.to_s + "人)" %>
<li class="classbox" id="group_name_<%= group.id %>"> <li class="classbox" id="group_name_<%= group.id %>" name="check_group_name">
<%= form_tag(searchgroupmembers_course_path(@course,:group_id => group.id), method: 'get', remote: true) do %> <%= link_to group_display, searchgroupmembers_course_path(@course,:group_id => group.id), method: 'get', remote: true,
<%#= text_field_tag "group_id", params[:group_id] %> :onclick => "checkclass('group_name_#{group.id}')",:style => " border:0px; color: #0d90c3; float:left;"%>
<%= submit_tag group_display, :onclick => "$asign_id(#{group.id})",:style => "background: #f8df8c; border:0px; color: black; float:left;"%> <% if @canShowCode %>
<% 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>
<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 %>
</li> </li>
<li> <li>
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), 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">

View File

@ -1,13 +1,20 @@
<div > <div style="margin-left: 15px">
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %> <% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<% if !@canShowCode %> <% if !@canShowCode %>
<%= join_in_course_group(@course.course_groups,@group, User.current) %> <%= join_in_course_group(@course.course_groups,@group, User.current) %>
<% end %>&nbsp;&nbsp;&nbsp; <% end %>&nbsp;&nbsp;&nbsp;
<span style="font-size: 18px"><%= @group.name %><%= @subPage_title %></span> <span style="font-size: 18px; float: left; margin-right: 35px"><%= l(:label_current_group)%>:&nbsp;<%= @group.name %></span>
<% end %>
<% if @show_serch%>
<%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:style => "margin-left: 5px; ",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'f_1', :style => "height:15px"%>
<%= submit_tag l(:label_search), :class => "f_2"%>
<%#= link_to l(:label_search),'' , :class => 'f_2' %>
<% end %>
<% end %>
<% end %>
</div> </div>
<div class="cl"></div>
<% if members.any? %> <% if members.any? %>
<% if @result_count %> <% if @result_count %>
<p style="font-size: 18px;"><%= l(:label_search_member_count) %><%= @result_count %><%= l(:label_member_people) %></p> <p style="font-size: 18px;"><%= l(:label_search_member_count) %><%= @result_count %><%= l(:label_member_people) %></p>

View File

@ -3,20 +3,14 @@
<div class="st_list"> <div class="st_list">
<div class="st_search"> <div class="st_search">
<span class="f_l"><%= @subPage_title %></span> <span class="f_l"><%= @subPage_title %></span>
<% if @subPage_title == l(:label_student_list) %>
<%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'f_1'%>
<%= submit_tag l(:label_search), :class => "f_2"%>
<%#= link_to l(:label_search),'' , :class => 'f_2' %>
<% end %>
<% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<% if @subPage_title == l(:label_student_list) %>
<div class="st_addclass" id = "st_groups"> <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>

View File

@ -572,6 +572,7 @@ zh:
label_member: label_member:
label_search_member_count: 共搜索到 label_search_member_count: 共搜索到
label_member_people: label_member_people:
label_current_group: 当前分班
label_limit_groupname: 组别名不能超出20字符 label_limit_groupname: 组别名不能超出20字符
label_limit_groupname_null: 组别名不能为空 label_limit_groupname_null: 组别名不能为空
label_member_new: 添加成员 label_member_new: 添加成员
@ -1906,7 +1907,9 @@ zh:
label_bids_task_list: 作业列表 label_bids_task_list: 作业列表
label_join_course: 加入 label_join_course: 加入
label_exit_course: 退出 label_exit_course: 退出
label_exit_group: 退出当前分班
label_new_join: 加入 label_new_join: 加入
label_new_join_group: 加入当前分班
label_new_course_password: 课程密码 label_new_course_password: 课程密码
label_new_course_school: 开课学校 label_new_course_school: 开课学校
label_new_course_description: 课程描述 label_new_course_description: 课程描述

View File

@ -20,9 +20,9 @@ a:hover{ }
.c_red{ color:#ec0016;} .c_red{ color:#ec0016;}
.w90{width:90px;} .w90{width:90px;}
.ml10{margin-left:10px;} .ml10{margin-left:10px;}
.st_search input.f_2 { input.f_2 {
width:60px !important; width:60px !important;
height:28px !important; height:24px !important;
color:#fff !important; color:#fff !important;
margin-right:5px !important; margin-right:5px !important;
border:none !important; border:none !important;
@ -45,6 +45,7 @@ a:hover{ }
/*.st_search input.f_2{ background:#1c9ec7; padding: 3px; margin-left: 3px; color:#fff;border:1px solid #1c9ec7; text-align:center; display:block; width:45px; height:28px; font-size:12px; }*/ /*.st_search input.f_2{ background:#1c9ec7; padding: 3px; margin-left: 3px; color:#fff;border:1px solid #1c9ec7; text-align:center; display:block; width:45px; height:28px; font-size:12px; }*/
.classbox{ border:1px solid #f8df8c; background:#fffce6; color:#0d90c3; padding:0 3px; float:left; margin-left:15px;} .classbox{ border:1px solid #f8df8c; background:#fffce6; color:#0d90c3; padding:0 3px; float:left; margin-left:15px;}
.st_addclass ul li.selected { border:1px solid #f8df8c; background:#f8df8c; color:#0d90c3; padding:0 3px; float:left; margin-left:15px;}
.st_addclass{ margin-top:5px;} .st_addclass{ margin-top:5px;}
.st_addclass ul li{ margin-bottom:10px;} .st_addclass ul li{ margin-bottom:10px;}
.st_addclass ul li,.st_addclass a,.st_addclass img{ float:left;} .st_addclass ul li,.st_addclass a,.st_addclass img{ float:left;}
@ -81,16 +82,17 @@ a:hover.st_add{ color:#ff8e15;}
.submit_2{height:21px;border:0; cursor:pointer; background:url(../images/btn1.png) no-repeat 0 0;width:42px; margin-top:2px; margin-left:3px; } .submit_2{height:21px;border:0; cursor:pointer; background:url(../images/btn1.png) no-repeat 0 0;width:42px; margin-top:2px; margin-left:3px; }
.isTxt{background:#fbfbfb url(../images/inputBg.png) repeat-x left top;height:22px;line-height:22px;border:1px solid #c1c1c1;padding:0 5px;color:#666666;} .isTxt{background:#fbfbfb url(../images/inputBg.png) repeat-x left top;height:22px;line-height:22px;border:1px solid #c1c1c1;padding:0 5px;color:#666666;}
.group_in { .group_in {
width:60px !important; width:90px !important;
height:28px !important; height:28px !important;
color:#fff !important; color:#1c9ec7!important;
margin-right:5px !important; margin-right:5px !important;
border:none !important; border:none !important;
font-size: 14px !important;
margin-left:0px !important; margin-left:0px !important;
box-shadow: none !important; box-shadow: none !important;
float: right;
border-radius: 0 !important; border-radius: 0 !important;
text-shadow: none !important; text-shadow: none !important;
border:1px solid #1c9ec7; padding: 0px !important;
background:#1c9ec7; background:#ffffff !important;
} }