Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
huang 2016-07-01 17:53:47 +08:00
commit 374a905d1e
22 changed files with 119 additions and 71 deletions

View File

@ -5,8 +5,8 @@ class SyllabusesController < ApplicationController
include AttachmentsHelper
include CoursesHelper
before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy]
before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :update_base_info]
before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus]
before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :update_base_info, :delete_syllabus, :delete_des]
def index
user = User.current
@syllabuses = user.syllabuses
@ -55,6 +55,12 @@ class SyllabusesController < ApplicationController
end
end
def delete_syllabus
respond_to do |format|
format.js
end
end
def update
@syllabus.description = params[:syllabus][:description]
@syllabus.des_status = 1
@ -71,10 +77,21 @@ class SyllabusesController < ApplicationController
end
#删除课程大纲的描述
def delete_des
if @syllabus
@syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content
@syllabus.des_status = 0
@syllabus.attachments.destroy_all
if @syllabus.save
redirect_to syllabus_path(@syllabus)
end
end
end
def destroy
if @syllabus && @syllabus.courses.empty?
@syllabus.destroy
redirect_to user_path(User.current.id)
redirect_to user_courselist_user_path(User.current.id)
end
end

View File

@ -3193,9 +3193,6 @@ class UsersController < ApplicationController
sort_name = "updated_at"
sort_type = @c_sort == 1 ? "asc" : "desc"
# @courses = @user.courses.visible.where("is_delete =?", 0).order("#{sort_name} #{sort_type}")
#@courses = @user.courses.visible.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 = @user.courses.visible.where("is_delete =?", 0)
syllabus_ids = @courses.empty? ? '(-1)' : "(" + @courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
@syllabus = Syllabus.where("id in #{syllabus_ids} or user_id = #{User.current.id}").order("#{sort_name} #{sort_type}")
@ -3203,12 +3200,6 @@ class UsersController < ApplicationController
#根据 作业+资源数排序
if @order.to_i == 2
@type = 2
# @courses.each do |course|
# course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
# if course[:infocount] < 0
# course[:infocount] = 0
# end
# end
@syllabus.each do |syllabus|
count = 0
courses = @courses.where("syllabus_id = #{syllabus.id}")

View File

@ -1079,6 +1079,8 @@ module ApplicationHelper
title << @organization.name
elsif @user
title << @user.try(:realname)
elsif @syllabus
title << @syllabus.title
else
title << (User.current.id == 2 ? "未登录" : User.current.try(:realname))
end

View File

@ -78,7 +78,7 @@
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@new_course.end_time),@new_course.end_time), {:id=>"new_end_time"} %>
<%= select_tag :end_term,options_for_select(course_term_option,@new_course.end_term || cur_course_term),{:id=>"new_end_term"} %>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则与开始学期保持一致。</span>
</li>
<div class="cl"></div>
<!--<li class="ml45 mb10">
@ -98,7 +98,7 @@
<li class=" mb5 ml85">
<label >公开&nbsp;&nbsp;</label>
<input <%= @course.is_public == 1 ? 'checked' : ''%> id="course_is_public" name="course[is_public]" type="checkbox" value="<%=@course.is_public.to_i %>">
<span class="c_grey">(选中后班级外用户可见该班级,否则仅对班级内成员可见)</span>
<span class="c_grey">(选中后对所有用户可见,否则仅对本班级成员可见)</span>
<div class="cl"></div>
</li>
<li class="ml85">

View File

@ -12,7 +12,7 @@
<span><%=@syllabus.title %></span>
<input style="display: none;" name="syllabus_id" value="<%=@syllabus.id %>" />
<% end %>
<span class="c_red" id="new_syllabus_notice" style="display: none;">请选择课程大纲</span>
<span class="c_red" id="new_syllabus_notice" style="display: none;">如果列表中没有对应的课程,请您先<%=link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'ml5 green_btn_share c_white'%></span>
</li>
<div class="cl"></div>
<li class="ml45">
@ -38,7 +38,7 @@
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"new_end_time"} %>
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"new_end_term"} %>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则与开始学期保持一致。</span>
</li>
<div class="cl"></div>
<!--<li class="ml45 mb10">
@ -58,13 +58,13 @@
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<span class="c_grey">(选中后班级外用户可见该班级,否则仅对班级内成员可见)</span>
<span class="c_grey">(选中后对所有用户可见,否则仅对本班级成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
<span class="c_grey">(选中后班级外用户可见学生列表,否则仅对班级内成员可见)</span>
<span class="c_grey">(选中后对所有用户可见,否则仅对本班级成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">

View File

@ -31,8 +31,8 @@
</li>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_syllabus_name)%>&nbsp;&nbsp;</label>
<%= select_tag :syllabus_id,options_for_select(syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input"} %>
<span class="c_red" id="edit_syllabus_notice" style="display: none;">请选择课程大纲</span>
<%= select_tag :syllabus_id,options_for_select(syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:280px'} %>
<span class="c_red" id="edit_syllabus_notice" style="display: none;">如果列表中没有对应的课程,请您先<%=link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'ml5 green_btn_share c_white'%></span>
</li>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
@ -76,13 +76,13 @@
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input <%= @course.is_public == 1 ? 'checked' : ''%> id="course_is_public" name="course[is_public]" type="checkbox">
<span class="c_grey">(选中后班级外用户可见该班级,否则仅对班级内成员可见)</span>
<span class="c_grey">(选中后对所有用户可见,否则仅对本班级成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input <%= @course.open_student == 1 ? 'checked' : ''%> id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/>
<span class="c_grey">(选中后班级外用户可见学生列表,否则仅对班级内成员可见)</span>
<span class="c_grey">(选中后对所有用户可见,否则仅对本班级成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">

View File

@ -9,14 +9,16 @@
<%= image_tag(url_to_avatar(@course), :width => "60", :height => "60") %>
</div>
<div class="pr_info_id fl f14">
<span class="hidden fl" style="max-width: 90px;" title="<%= @course.name %>"><%= @course.name %></span><span class="fl"><%=@course.is_public == 1 ? '(私有)' : '公开' %></span>
</br>
<div class="cl"></div>
<% if @course.syllabus%>
<a class="pr_info_name fb c_dark fl hidden" style="max-width: 120px;" href="<%= Setting.protocol%>://<%= Setting.host_name%>/syllabuses/<%= @course.syllabus_id%>" target="_blank">
<a class="pr_info_name fb c_dark fl hidden" title="<%=@course.syllabus.title %>" style="max-width: 120px;" href="<%= Setting.protocol%>://<%= Setting.host_name%>/syllabuses/<%= @course.syllabus_id%>" target="_blank">
<%=@course.syllabus.title %>
</a>
<% end %>
<div class="cl"></div>
<span class="hidden fl" style="max-width: 80px;" title="<%= @course.name %><%=@course.is_public == 0 ? '(私有)' : '(公开)' %>"><%= @course.name %></span><span class="fl"><%=@course.is_public == 0 ? '(私有)' : '(公开)' %></span>
</br>
<div class="cl"></div>
<% if is_excellent_course(@course) %>
<img src="/images/course/medal.png" alt="精品课程" style="vertical-align:bottom;" class="ml5" />
<% end %>

View File

@ -48,7 +48,7 @@
<li class="none none_attr"><label>先修课程:</label><span class="fontGrey3">空</span></li>
<% end %>
</ul>
<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?) %>
<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?)&&(syllabus.syllabus_type.nil? || syllabus.syllabus_type == ''||syllabus.credit.nil? || syllabus.credit == ''||syllabus.hours.nil? || syllabus.hours == ''||syllabus.theory_hours.nil? || syllabus.theory_hours == ''||syllabus.practice_hours.nil? || syllabus.practice_hours == ''||syllabus.applicable_major.nil? || syllabus.applicable_major == ''||syllabus.pre_course.nil? || syllabus.pre_course == '')%>
<span class="homepageLeftMenuMore"><a href="javascript:void(0);" data-init="0" onclick="toggle_all_syllabus_attr();" class="homepageLeftMenuMoreIcon" id="show_all_syllabus_attr"></a></span>
<% end %>
<script>

View File

@ -5,7 +5,7 @@
<%= image_tag("../images/syllabus.jpg",width:"60px", height: "60px") %>
</div>
<div class="fl ml15">
<p class="homepageImageName mb5"><%=@syllabus.title %></p>
<p class="homepageSyllabusName mb5" title="<%=@syllabus.title %>"><%=@syllabus.title %></p>
<div class="cl"></div>
</div>
<div class="cl"></div>

View File

@ -2,7 +2,7 @@
<li class="homepageLeftMenuCoursesLine pr">
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>
<%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}",
:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程")+course.name+""+current_time_and_term(course)+""%>
:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级")+course.name+""+current_time_and_term(course)+""%>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>

View File

@ -12,7 +12,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application','prettify', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application','prettify','public', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_include_tag 'prettify' %>
<%= javascript_heads %>

View File

@ -30,8 +30,8 @@
:remote => true,
:method => :post,
:id => 'new_join_course') do %>
<label>请输入课程密码:</label>
<%= text_field_tag 'course_password', nil, :style=>'width:300px;'%>
<label>请输入班级邀请码:</label>
<%= text_field_tag 'invite_code', nil, :style=>'width:300px;'%>
<div class="ni_btn">
<a href="javascript:" class="tijiao" onclick="$('#new_join_course').submit();" >
确&nbsp;&nbsp;定

View File

@ -0,0 +1,17 @@
<br>
<div style='width:470px;text-align:center;font-family: "微软雅黑","宋体"' class="f14">
<% if @syllabus.courses.empty? %>
确认删除该课程吗?
<% else %>
该课程下已经存在班级,不能删除。
<% end %>
</div>
</br>
<div style='width:164px; margin:0 auto; text-align:center; font-family: "微软雅黑","宋体"'>
<% if @syllabus.courses.empty? %>
<%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%>
<a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>关闭</a>
<% else %>
<a href='javascript:void(0);' class='Blue-btn' style="margin-left: 50px;" onclick='hideModal()'>关闭</a>
<% end %>
</div>

View File

@ -0,0 +1,2 @@
var htmlvalue = "<%=escape_javascript(render :partial => 'delete_syllabus') %>";
pop_up_box(htmlvalue,500,30,50);

View File

@ -5,7 +5,7 @@
<p >课程信息</p>
</div>
<div class="HomeWork">
<p class="f16 mb10">课程信息</p>
<p class="f16 mb10"><%=@syllabus.title %>课程大纲</p>
<div class="HomeWorkCon">
<%= labelled_form_for @syllabus, :url =>syllabus_path(@syllabus),
:html => {:nhname=>'form',:multipart => true, :id => 'syllabus-form'} do |f| %>

View File

@ -13,11 +13,11 @@
<div class="syllabusbox_tishi">
<% if User.current == @syllabus.user %>
<p >您建立的课程还未创建班级,请
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "syllabusbox_a_blue", :target => '_blank'%>
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "syllabusbox_a_blue", :target => '_blank'%>
</p>
<% elsif User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
<p >本课程下还未创建班级,请
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "syllabusbox_a_blue", :target => '_blank'%>
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "syllabusbox_a_blue", :target => '_blank'%>
</p>
<% else %>
<p >本课程下还未创建班级,敬请期待。
@ -45,9 +45,7 @@
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%=link_to '编辑', edit_syllabus_path(@syllabus), :class => 'postOptionLink'%></li>
<% if @syllabus.courses.empty? %>
<li><%=link_to '删除', syllabus_path(@syllabus), :class => 'postOptionLink', :method => 'delete', :data => {:confirm => l(:text_are_you_sure)}%></li>
<% end %>
<li><%=link_to '删除', delete_des_syllabus_path(@syllabus), :class => 'postOptionLink', :confirm => l(:text_are_you_sure)%></li>
</ul>
</li>
</ul>

View File

@ -23,7 +23,7 @@
<% courses = @courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("time desc") %>
<div class="syllabus_courses_list">
<div class="<%=index == 0 ? 'sy_courses_open' : 'sy_courses_close' %>">
<span class="<%=index == 0 ? 'icons_sy_open' : 'icons_sy_close' %> fl mr5"></span>
<span class="<%=index == 0 && !courses.empty? ? 'icons_sy_open' : 'icons_sy_close' %> fl mr5"></span>
<h3 class="syllabus_courses_title fl"><%=syllabus.title %></h3>
</div>
<p class="fl sy_p_grey">更新时间:<%=format_date syllabus.updated_at %>
@ -66,8 +66,20 @@
</ul>
</div><!--syllabus_class_box end-->
<%=link_to '', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr',:target =>'_blank', :title => '查看课程' %>
<div class="homepagePostSetting">
<ul>
<li class="icons_sy_setting">
<ul class="homepagePostSettiongText">
<li>
<%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
</li>
<% if User.current == syllabus.user %>
<li><%=link_to '删除', delete_syllabus_syllabus_path(syllabus), :class => 'postOptionLink', :remote => 'true'%></li>
<% end %>
</ul>
</li>
</ul>
</div>
</div>
<% end %>
<div>
@ -94,7 +106,9 @@
$(".syllabus_courses_list").each(function(){
var syStaust = $(this).children(":first-child");
var classNum = $(this).next().children().children("li").size();
if(classNum>0){
if (syStaust.hasClass("sy_courses_open")){
$(this).toggle(function(){
$(this).next().hide();
@ -112,6 +126,7 @@
$(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open");
});
}
}
});
});
</script>

View File

@ -188,7 +188,7 @@ zh:
text_are_you_sure: 您确定要删除吗? #js 提示
text_are_you_sure_out: 你确定要退出该课程吗?
text_are_you_sure_out: 你确定要退出该班级吗?
text_are_you_sure_out_group: 你确定要退出该分班吗?
text_are_you_sure_all: 您确定要删除所有文件吗

View File

@ -1086,6 +1086,8 @@ RedmineApp::Application.routes.draw do
match 'syllabus_courselist', :to => 'syllabuses#syllabus_courselist', :via => :get, :as => 'syllabus_courselist'
get 'edit_syllabus_eng_name'
post 'update_base_info'
get 'delete_syllabus'
get 'delete_des'
end
collection do

View File

@ -1545,6 +1545,17 @@ function show_edit_file_description(id) {
$("#file_description_edit_"+id).focus();
}
//编辑资源描述之后提交
function edit_file_description(url,id){
$.get(
url,
{id: id ,description: $("#file_description_edit_"+id).val() },
function (data) {
}
);
}
//展开课程大纲列表中的班级
function expand_course_list(id, target, btnid, count) {
var target = $(target);

View File

@ -48,17 +48,6 @@ function edit_syllabus_eng_name(url){
);
}
//编辑资源描述之后提交
function edit_file_description(url,id){
$.get(
url,
{id: id ,description: $("#file_description_edit_"+id).val() },
function (data) {
}
);
}
//展开所有属性
function toggle_all_syllabus_attr(){
var btn = $("#show_all_syllabus_attr");

View File

@ -4,7 +4,7 @@
a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;}
.submit{height:21px;border:0; cursor:pointer; background:url(../images/btn.png) no-repeat 0 0;width:42px; margin-top:2px; margin-left:3px; }
.isTxt{background:#fbfbfb url(../images/inputBg.png) repeat-x left top;height:22px;line-height:22px;border:1px solid #c1c1c1;padding:0 5px;color:#666666;}
.re_tag{ width: auto; padding:0 5px; padding-top:2px; height:20px; border:1px solid #f8df8c; background:#fffce6; margin-right:5px; }
.re_tag{ width: auto; padding:0 5px; padding-top:2px; border:1px solid #f8df8c; background:#fffce6; margin-right:5px; }
.re_tag a{ color:#0d90c3;}
.tag_h{ }
.tag_h span,.tag_h a{ margin-bottom:5px;}
@ -154,3 +154,5 @@ a:hover.course-title{ color:#269ac9;}
/*新建页面*/
.name_input{ border:1px solid #64bdd9; height:16px; width:310px; background:#fff; margin-bottom:10px; padding:5px;}
.homepageSyllabusName {font-size:16px; color:#484848; height:25px; float:left; font-weight: bold; max-width:120px;overflow: hidden; white-space:nowrap; text-overflow:ellipsis;}