课程大纲下的班级归档
This commit is contained in:
parent
db71b1578b
commit
1fcb1db27c
|
@ -23,7 +23,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
before_filter :can_show_course, :except => []
|
||||
before_filter :logged_user_by_apptoken,:only => [:show,:feedback]
|
||||
before_filter :find_course, :except => [ :index, :search, :new,:join,:unjoin, :create, :new_join, :course,:join_private_courses, :join_course_multi_role]
|
||||
before_filter :find_course, :except => [ :index, :search, :new, :join, :unjoin, :create, :new_join, :course, :join_private_courses, :join_course_multi_role]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :update, :course]
|
||||
before_filter :authorize_course_global, :only => [:new,:create]
|
||||
before_filter :toggleCourse, :only => [:finishcourse, :restartcourse]
|
||||
|
@ -832,11 +832,11 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
if @course
|
||||
#发送微信消息
|
||||
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{User.current.id} and shield_type='Course' and shield_id=#{@course.id}").count
|
||||
# if count == 0
|
||||
# ss = SyllabusesService.new
|
||||
# ss.send_wechat_create_class_notice User.current,@course
|
||||
# end
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{User.current.id} and shield_type='Course' and shield_id=#{@course.id}").count
|
||||
if count == 0
|
||||
ss = SyllabusesService.new
|
||||
ss.send_wechat_create_class_notice User.current,@course
|
||||
end
|
||||
respond_to do |format|
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
format.html {redirect_to course_url(@course)}
|
||||
|
@ -1306,6 +1306,21 @@ class CoursesController < ApplicationController
|
|||
redirect_to user_url(User.current)
|
||||
end
|
||||
|
||||
#归档班级
|
||||
def archive_course
|
||||
if params[:source] == "1"
|
||||
@syllabus = @course.syllabus
|
||||
end
|
||||
if params[:type] == "0"
|
||||
@course.delete!
|
||||
else
|
||||
@course.update_attribute(:is_delete, false)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 恢复已删除的课程
|
||||
def renew
|
||||
if User.current.admin?
|
||||
|
|
|
@ -96,8 +96,10 @@ class SyllabusesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#班级列表
|
||||
|
||||
#班级列表 list_type: 1 班级列表 2 归档班级列表
|
||||
def syllabus_courselist
|
||||
@list_type = params[:list_type].to_i || 0
|
||||
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type
|
||||
|
@ -110,7 +112,7 @@ class SyllabusesController < ApplicationController
|
|||
sort_name = "updated_on"
|
||||
sort_type = @c_sort == 1 ? "asc" : "desc"
|
||||
|
||||
@courses = @syllabus.courses.where("is_delete = ?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
|
||||
@courses = @syllabus.courses.where("is_delete = ?", @list_type).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
|
||||
|
||||
#根据 作业+资源数排序
|
||||
if @order.to_i == 2
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<% if params[:type] == "0" %>
|
||||
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
||||
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>已归档</p>' +
|
||||
'<a href="javascript:void(0);" class="btn btn-blue mt10" onclick="click_OK();">确定</a></div></div></div>';
|
||||
<% else %>
|
||||
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
||||
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>已恢复</p>' +
|
||||
'<a href="javascript:void(0);" class="btn btn-blue mt10" onclick="click_OK();">确定</a></div></div></div>';
|
||||
<% end %>
|
||||
pop_box_new(htmlvalue, 400, 132);
|
||||
|
||||
function click_OK(){
|
||||
hideModal();
|
||||
<% if params[:source] == "1" %>
|
||||
window.location.href = "<%=syllabus_courselist_syllabus_path(@syllabus, :list_type => params[:type].to_i) %>";
|
||||
<% end %>
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
<% if @syllabus.nil? %>
|
||||
<%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input w300 h28"} %>
|
||||
<% else %>
|
||||
<span><%=@syllabus.title %></span>
|
||||
<span id="course_syllabus_title"><%=@syllabus.title %></span>
|
||||
<input style="display: none;" name="syllabus_id" value="<%=@syllabus.id %>" />
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta name="keywords" content="issue,bug,tracker" />
|
||||
<%= csrf_meta_tag %>
|
||||
<%= favicon %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public','css/structure','css/courses','css/popup','prettify','syllabus','sy_public',:media => 'all'%>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public','css/structure','css/courses','css/popup','prettify','syllabus','sy_public','css/moduel',:media => 'all'%>
|
||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||
<%= javascript_heads %>
|
||||
<%= javascript_include_tag "bootstrap","avatars","course",'attachments','prettify','syllabus','cookie'%>
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
<% if @courses.any? %>
|
||||
<div class="sy_category">
|
||||
<span class="sy_cgrey ">排序:</span>
|
||||
<%= link_to "时间", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sy_cgrey fl", :remote => true %>
|
||||
<%= link_to "时间", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 1, :list_type => @list_type}, :class => "sy_cgrey fl", :remote => true %>
|
||||
<% if @type.to_i == 1 %>
|
||||
<%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 1, :list_type => @list_type}, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<% end %>
|
||||
<%= link_to "人气", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sy_cgrey fl #{@type == 1 ? '' : 'ml10'}", :remote => true %>
|
||||
<%= link_to "人气", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2, :list_type => @list_type}, :class => "sy_cgrey fl #{@type == 1 ? '' : 'ml10'}", :remote => true %>
|
||||
<% if @type.to_i == 2 %>
|
||||
<%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2, :list_type => @list_type}, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} mt15 fl", :remote => true %>
|
||||
<% end %>
|
||||
<% if @syllabus.syllabus_members.map{|sm| sm.user_id}.include?(User.current.id) %>
|
||||
<% archive_courses = @syllabus.courses.where("is_delete = ?", 1).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updated_time").order("updated_time desc") %>
|
||||
<% if @list_type == 0 && @syllabus.syllabus_members.map{|sm| sm.user_id}.include?(User.current.id) %>
|
||||
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_btn_green fr mt10 mr15", :target => '_blank'%>
|
||||
<% unless archive_courses.blank? %>
|
||||
<%= link_to "归档管理", syllabus_courselist_syllabus_path(@syllabus, :list_type => 1), :class => "linkBlue2 fr mr20 f14"%>
|
||||
<% end %>
|
||||
<% elsif @list_type == 1 && @syllabus.syllabus_members.map{|sm| sm.user_id}.include?(User.current.id) %>
|
||||
<%= link_to "返回", syllabus_courselist_syllabus_path(@syllabus), :class => "linkBlue2 fr mr15 f14"%>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -18,12 +24,12 @@
|
|||
<% @courses.each do |course| %>
|
||||
<ul class="sy_classlist">
|
||||
<div class="fl">
|
||||
<% if course.is_public == 0 && !User.current.member_of_course?(course) && !User.current.admin? %>
|
||||
<h3 class="sy_classlist_title fl">
|
||||
<% if (course.is_public == 0 && !User.current.member_of_course?(course) && !User.current.admin?) || @list_type == 1 %>
|
||||
<h3 class="sy_classlist_title fl" style="max-width: 530px;">
|
||||
<%=course.name %>(<%=current_time_and_term_short(course) %>)
|
||||
</h3>
|
||||
<% else %>
|
||||
<h3 class="sy_classlist_title fl">
|
||||
<h3 class="sy_classlist_title fl" style="max-width: 530px;">
|
||||
<%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course),
|
||||
:style => 'color:#000',:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+"("+current_time_and_term(course)+")"%>
|
||||
</h3>
|
||||
|
@ -38,14 +44,14 @@
|
|||
<% homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
|
||||
<% end %>
|
||||
<span class=" mr15">作业:
|
||||
<% if course.is_public == 0 && !User.current.member_of_course?(course) %>
|
||||
<% if (course.is_public == 0 && !User.current.member_of_course?(course)) || @list_type == 1 %>
|
||||
<%=homework_num %>
|
||||
<% else %>
|
||||
<%= link_to homework_num, homework_common_index_path(:course => course.id), :class => "sy_cblue",:target => '_blank'%>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class=" mr15">资源:
|
||||
<% if course.is_public == 0 && !User.current.member_of_course?(course) %>
|
||||
<% if (course.is_public == 0 && !User.current.member_of_course?(course)) || @list_type == 1 %>
|
||||
<%=visable_attachemnts_incourse(course).count %>
|
||||
<% else %>
|
||||
<%= link_to visable_attachemnts_incourse(course).count, course_files_path(course), :class => "sy_cblue",:target => '_blank'%>
|
||||
|
@ -55,11 +61,20 @@
|
|||
<span class=" mr15">更新时间:<%= format_date(course.updated_on) %></span>
|
||||
</p>
|
||||
</div>
|
||||
<% if @list_type == 0 %>
|
||||
<% if User.current.member_of_course?(course) %>
|
||||
<%=link_to '进入班级', course_path(course), :class => 'btn_orange_big fr mt5', :target => '_blank' %>
|
||||
<% else %>
|
||||
<%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "hw_btn_green fr mt5",:method => "post"%>
|
||||
<% end %>
|
||||
<% if User.current.allowed_to?(:as_teacher, course) || User.current.admin? %>
|
||||
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 0);" class="btn_grey_big fr mt5 mr5" style="width: 56px;">归档</a>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if User.current.allowed_to?(:as_teacher, course) || User.current.admin? %>
|
||||
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 1);" class="btn_grey_big fr mt5" style="width: 56px;">恢复</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
@ -71,14 +86,31 @@
|
|||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% if !User.current.member_of_syl?(@syllabus) %>
|
||||
<div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">该课程还未创建班级,敬请期待!</p>
|
||||
<% elsif @list_type == 0 %>
|
||||
<% if @syllabus.courses.where("is_delete = ?", 1).count == 0 %>
|
||||
<div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<% if User.current.member_of_syl?(@syllabus) %>
|
||||
<p class="sy_tab_con_p">该课程还未创建班级,请
|
||||
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_corange", :target => '_blank'%>
|
||||
,谢谢啦!<br/>只有创建班级后才可以开展在线教学哦~
|
||||
</p>
|
||||
<% else %>
|
||||
<p class="sy_tab_con_p">该课程还未创建班级,敬请期待!</p>
|
||||
<div class="sy_category" style="border-bottom-color: #fff;">
|
||||
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_btn_green fr mt10 mr15", :target => '_blank'%>
|
||||
<%= link_to "归档管理", syllabus_courselist_syllabus_path(@syllabus, :list_type => 1), :class => "linkBlue2 fr mr20 f14"%>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">该课程的班级已全部归档</p>
|
||||
<% end %>
|
||||
<% elsif @list_type == 1 %>
|
||||
<div class="sy_category" style="border-bottom-color: #fff;">
|
||||
<%= link_to "返回", syllabus_courselist_syllabus_path(@syllabus), :class => "linkBlue2 fr mr15 f14"%>
|
||||
<div class="cl"></div>
|
||||
</div><div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">该课程下无归档的班级</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
@ -87,4 +119,19 @@
|
|||
$(function() {
|
||||
$(".sy_con_l").css("min-height",$(".sy_con_r").height());
|
||||
});
|
||||
function archive_course(id, type){
|
||||
if(type == 0){
|
||||
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
||||
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>您是否确定归档此班级</p>' +
|
||||
'<a href="javascript:void(0);" class="btn btn-grey mt10 mr10" onclick="hideModal();">取 消</a>' +
|
||||
'<a href="/courses/'+ id +'/archive_course?source=1&type=0" class="btn btn-blue mt10" onclick="hideModal();" data-remote="true">确 定</a></div></div></div>';
|
||||
pop_box_new(htmlvalue, 400, 132);
|
||||
} else{
|
||||
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
||||
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>您和您的学生将可以重新在此班级中互动<br/>此班级的动态会在首页中显示<br/><br/>' +
|
||||
'您是否确定恢复此班级</p><a href="javascript:void(0);" class="btn btn-grey mt10 mr10" onclick="hideModal();">取 消</a>' +
|
||||
'<a href="/courses/'+ id +'/archive_course?source=1&type=1" class="btn btn-blue mt10" onclick="hideModal();" data-remote="true">确 定</a></div></div></div>';
|
||||
pop_box_new(htmlvalue, 400, 200);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1243,6 +1243,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'search_not_group_member'
|
||||
post 'add_members'
|
||||
get 'delete_member'
|
||||
get 'archive_course'
|
||||
end
|
||||
collection do
|
||||
match 'join_private_courses', :via => [:get, :post]
|
||||
|
|
|
@ -81,7 +81,11 @@ function regex_course_name(str)
|
|||
if($("#new_syllabus_id").length > 0){
|
||||
syl_title = $("#new_syllabus_id").find("option:selected").text();
|
||||
} else{
|
||||
if(str == "edit"){
|
||||
syl_title = $("#edit_syllabus_id").html();
|
||||
} else{
|
||||
syl_title = $("#course_syllabus_title").html();
|
||||
}
|
||||
}
|
||||
if(name.length < 2)
|
||||
{
|
||||
|
|
|
@ -549,6 +549,24 @@ a:hover.BlueCirBtnMini{ background:#3598db; color:#fff;}
|
|||
a.BlueCirBtnMiddle{ display:block;width:50px; height:24px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
|
||||
a:hover.BlueCirBtnMiddle{ background:#3598db; color:#fff;}
|
||||
/* 按钮*/
|
||||
a.btn_grey_big{
|
||||
display: inline-block;
|
||||
border: 1px solid #ccc;
|
||||
color: #747474;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
padding:0 10px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
-webkit-border-radius:3px;
|
||||
-moz-border-radius:3px;
|
||||
-o-border-radius:3px;
|
||||
border-radius:3px;
|
||||
}
|
||||
a:hover.btn_grey_big{
|
||||
background: #c3c3c3;
|
||||
color: #fff;
|
||||
}
|
||||
a.btn_orange_big{
|
||||
display:inline-block;
|
||||
border: 1px solid #ee4a1f;
|
||||
|
|
Loading…
Reference in New Issue