学生加入课程或退出课程

This commit is contained in:
cxt 2016-01-26 15:59:39 +08:00
parent 76063b0911
commit af7ca36c92
2 changed files with 8 additions and 6 deletions

View File

@ -697,17 +697,16 @@ module CoursesHelper
def join_in_course_header(course, user, options=[])
if user.logged?
joined = course.members.map{|member| member.user_id}.include? user.id
text = joined ? ("<em class='pr_arrow'></em>".html_safe + l(:label_course_exit_student)) : ("<em class='pr_add'></em>".html_safe + l(:label_course_join_student))
text = joined ? l(:label_course_exit_student) : l(:label_course_join_student)
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post'
if joined
link = "<span class='pr_join_span mr5' ><em class='pr_add'></em>#{l(:label_course_join_student)}</span>" + link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
link = link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
else
link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a") + "<span class='pr_join_span mr5' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>".html_safe
link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a")
end
else
link = "<span class='pr_join_span mr5' ><em class='pr_add'></em>#{l(:label_course_join_student)}</span>" +
"<span class='pr_join_span mr5' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>"
link = "<span class='pr_join_span mr5' >#{l(:label_course_join_student)}</span>"
end
link.html_safe
end

View File

@ -15,7 +15,10 @@
<% end %>
</div>
<div class="pr_info_id fl f14">
<a href="" class="linkGrey">加入课程</a>
<% unless is_teacher %>
<!--<a href="" class="pr_join_a f12">加入课程</a>-->
<div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
<% end %>
</div>
<!--<div class="pr_info_id fl mb5 f14">
ID:<%#= @course.id%>