diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 81c21eb3d..98e195e30 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -242,9 +242,14 @@ class CoursesController < ApplicationController end def teacher_assign_group - member = Member.where(:course_id => @course.id, :user_id => User.current.id).first + member = Member.where(:course_id => @course.id, :user_id => params[:user_id]).first member.course_group_id = params[:course_group_id].to_i member.save + @course_groups = @course.course_groups + @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' + respond_to do |format| + format.js + end end def join_group diff --git a/app/views/courses/_new_member_list.html.erb b/app/views/courses/_new_member_list.html.erb index 12a5d9626..b399c6035 100644 --- a/app/views/courses/_new_member_list.html.erb +++ b/app/views/courses/_new_member_list.html.erb @@ -60,12 +60,12 @@ <% end%> <% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %> - <% if @course.course_groups.nil? %> + <% if @course.course_groups.nil? || @group %>
- +
<% 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 %> + <%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id,:user_id => member.user_id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %>
diff --git a/app/views/courses/teacher_assign_group.js.erb b/app/views/courses/teacher_assign_group.js.erb index e69de29bb..1429bb753 100644 --- a/app/views/courses/teacher_assign_group.js.erb +++ b/app/views/courses/teacher_assign_group.js.erb @@ -0,0 +1 @@ +$("#st_groups").html("<%=escape_javascript(render :partial => 'new_groups_name', :locals => {:course_groups => @course_groups}) %>"); \ No newline at end of file