学生加入课程或退出课程
This commit is contained in:
parent
76063b0911
commit
af7ca36c92
|
@ -697,17 +697,16 @@ module CoursesHelper
|
||||||
def join_in_course_header(course, user, options=[])
|
def join_in_course_header(course, user, options=[])
|
||||||
if user.logged?
|
if user.logged?
|
||||||
joined = course.members.map{|member| member.user_id}.include? user.id
|
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)
|
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
|
||||||
method = joined ? 'delete' : 'post'
|
method = joined ? 'delete' : 'post'
|
||||||
if joined
|
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
|
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
|
end
|
||||||
else
|
else
|
||||||
link = "<span class='pr_join_span mr5' ><em class='pr_add'></em>#{l(:label_course_join_student)}</span>" +
|
link = "<span class='pr_join_span mr5' >#{l(:label_course_join_student)}</span>"
|
||||||
"<span class='pr_join_span mr5' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>"
|
|
||||||
end
|
end
|
||||||
link.html_safe
|
link.html_safe
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pr_info_id fl f14">
|
<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>
|
||||||
<!--<div class="pr_info_id fl mb5 f14">
|
<!--<div class="pr_info_id fl mb5 f14">
|
||||||
ID:<%#= @course.id%>
|
ID:<%#= @course.id%>
|
||||||
|
|
Loading…
Reference in New Issue