老师把学生加入某一个分班

This commit is contained in:
cxt 2016-03-10 17:04:26 +08:00
parent c255325300
commit 0d8052da28
5 changed files with 51 additions and 10 deletions

View File

@ -240,6 +240,13 @@ class CoursesController < ApplicationController
# req[:message] = l(:modal_valid_passing) if req[:message].blank?
render :json => req
end
def teacher_assign_group
member = Member.where(:course_id => @course.id, :user_id => User.current.id).first
member.course_group_id = params[:course_group_id].to_i
member.save
end
def join_group
@subPage_title = l :label_student_list
group = CourseGroup.find(params[:object_id])

View File

@ -601,6 +601,24 @@ module CoursesHelper
Course.tagged_with(tag_name).order('updated_at desc')
end
#分班下拉框
def course_group_option course
type = []
option1 = []
option1 << "暂无"
option1 << 0
type << option1
unless course.course_groups.nil?
course.course_groups.each do |cg|
option = []
option << cg.name
option << cg.id
type << option
end
end
type
end
#课程实践年份下拉框
def course_time_option year
type = []

View File

@ -60,18 +60,30 @@
<% end%>
</ul>
<% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %>
<div class="select-class-option fl" style="margin-left: 105px;"><span style="width: 100px; text-align: center; float: left;" class="hidden">向日葵班</span>
<a style="display: inline-block;" href="javascript:void(0)" class="pic_edit2 ml5"></a></div>
<select class="w125 undis class-edit fl" style="margin-left: 105px;">
<option value="1" selected="selected">向日葵班</option>
<option value="2">学前班</option>
<option value="3">幼儿园</option>
<option value="4">小学</option>
<option value="5">初中</option>
</select>
<% if @course.course_groups.nil? %>
<div class="select-class-option fl" style="margin-left: 105px;">
<span style="width: 100px; text-align: center; float: left;" class="hidden">暂无</span>
</div>
<% else %>
<%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %>
<div class="select-class-option fl" style="margin-left: 105px;"><span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
<a style="display: inline-block;" href="javascript:void(0)" class="pic_edit2 ml5"></a>
</div>
<%= select( :name,:group_id, course_group_option(@course),
{ :include_blank => false,:selected => member.course_group_id},
{:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w125 undis class-edit fl", :style => "margin-left: 105px;"}) %>
<!--<select class="w125 undis class-edit fl" style="margin-left: 105px;">
<option value="1" selected="selected">向日葵班</option>
<option value="2">学前班</option>
<option value="3">幼儿园</option>
<option value="4">小学</option>
<option value="5">初中</option>
</select>-->
<% end %>
<% end %>
<% else %>
<div class="select-class-option fl" style="margin-left: 105px;">
<span style="width: 100px; text-align: center; float: left;" class="hidden"><%= %></span>
<span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
</div>
<% end %>
<%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
@ -127,5 +139,8 @@
stopPropagation(e);
});
});
function join_group_function(id){
$(id).submit();
}
</script>

View File

@ -1005,6 +1005,7 @@ RedmineApp::Application.routes.draw do
get 'course_outline'
post 'search_course_outline'
post 'set_course_outline'
post 'teacher_assign_group'
get 'syllabus'
get 'search_public_orgs_not_in_course'
get "homework_search"