加入课程、退出课程、配置、关闭、复制等按钮

This commit is contained in:
sw 2015-03-18 17:14:26 +08:00
parent 1c30b8c81c
commit 423849ca84
3 changed files with 38 additions and 5 deletions

View File

@ -665,4 +665,30 @@ module CoursesHelper
count = get_course_activity([course],course_activity_count)[course.id] count = get_course_activity([course],course_activity_count)[course.id]
count.nil? ? 0 : count count.nil? ? 0 : count
end end
#重启、关闭课程按钮
def set_course_time course
id = "finish_course_#{course.id}"
linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js)
desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed)
link_to "<span class='pr_close'></span>#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a"
end
def join_in_course_header(course, user, options=[])
if user.logged?
joined = user.member_of_course? course
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))
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' ><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))
else
link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a") + "<span class='pr_join_span' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>".html_safe
end
else
link = "<span class='pr_join_span' ><em class='pr_add'></em>#{l(:label_course_join_student)}</span>" +
"<span class='pr_join_span' ><em class='pr_arrow'></em>#{l(:label_course_exit_student)}</span>"
end
link.html_safe
end
end end

View File

@ -72,9 +72,13 @@
ID:<%= @course.id%> ID:<%= @course.id%>
</div> </div>
<div class="pr_info_join fl"> <div class="pr_info_join fl">
<a href="#" class="pr_join_a " ><span class="pr_setting"></span>配置</a> <% if is_teacher%>
<a href="#" class="pr_join_a" ><span class="pr_close"></span> 关闭</a> <%= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, {:controller => 'courses', :action => 'settings', :id => @course}, :class => "pr_join_a" %>
<a href="#" class="pr_join_a" ><em class="pr_copy"></em>复制</a> <%= set_course_time @course%>
<%= link_to "<span class='pr_copy'></span>#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %>
<% else%>
<%= join_in_course_header(@course, User.current) %>
<% end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -101,8 +105,10 @@
<ul> <ul>
<li><%= l(:label_main_teacher)%> :&nbsp;&nbsp;<%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher), :class => 'c_dblue') %></li> <li><%= l(:label_main_teacher)%> :&nbsp;&nbsp;<%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher), :class => 'c_dblue') %></li>
<li><%= l(:label_class_period)%> :&nbsp;&nbsp;<span ><%= @course.class_period %> <%= l(:label_class_hour) %></span></li> <li><%= l(:label_class_period)%> :&nbsp;&nbsp;<span ><%= @course.class_period %> <%= l(:label_class_hour) %></span></li>
<li><%= l(:label_main_term)%> :&nbsp;&nbsp;<span><%= @course.time %> <%= @course.try(:term).to_s %></span></li> <li><%= l(:label_main_term)%> :&nbsp;&nbsp;<span><%= @course.time %> <%= @course.term %></span></li>
<li><%= l(:label_course_organizers)%> :&nbsp;&nbsp;<a href="http://<%= Setting.host_course%>/?school_id=<%= @course.school.id%>" target="_blank" class="c_dblue"><%= @course.school%></a></li> <% if @course.school%>
<li><%= l(:label_course_organizers)%> :&nbsp;&nbsp;<a href="http://<%= Setting.host_course%>/?school_id=<%= @course.school.id%>" target="_blank" class="c_dblue"><%= @course.school%></a></li>
<% end%>
</ul> </ul>
</div> </div>

View File

@ -11,6 +11,7 @@ zh:
# 课程公共标签 # 课程公共标签
# #
label_course_join_student: 加入课程 label_course_join_student: 加入课程
label_course_exit_student: 退出课程
label_course_new: 新建课程 label_course_new: 新建课程
label_homework: 课程作业 label_homework: 课程作业