diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index a1c3f7665..8ff88823d 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 287e48111..69a38610e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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}") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ee2e2d74a..cb8b06a8f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index c1c4d1c2f..cc7f2fb53 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -78,7 +78,7 @@ <%= 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"} %> - 仅针对跨越多个学期的班级,否则不用修改。 + 仅针对跨越多个学期的班级,否则与开始学期保持一致。
- - <%=link_to '', syllabus_path(syllabus.id), :class => 'icons_sy_setting fr',:target =>'_blank', :title => '查看课程' %> +
+ +
<% end %>
@@ -94,23 +106,26 @@ $(".syllabus_courses_list").each(function(){ var syStaust = $(this).children(":first-child"); + var classNum = $(this).next().children().children("li").size(); - if (syStaust.hasClass("sy_courses_open")){ - $(this).toggle(function(){ - $(this).next().hide(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); - },function(){ - $(this).next().show(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); - }); - }else{ - $(this).toggle(function(){ - $(this).next().show(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); - },function(){ - $(this).next().hide(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); - }); + if(classNum>0){ + if (syStaust.hasClass("sy_courses_open")){ + $(this).toggle(function(){ + $(this).next().hide(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); + },function(){ + $(this).next().show(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); + }); + }else{ + $(this).toggle(function(){ + $(this).next().show(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); + },function(){ + $(this).next().hide(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); + }); + } } }); }); diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 70236d9ba..49d5f4d03 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -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: 您确定要删除所有文件吗 diff --git a/config/routes.rb b/config/routes.rb index 480dcc66d..38c59a014 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1084,6 +1084,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 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index f8dc114ef..016526512 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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); diff --git a/public/javascripts/syllabus.js b/public/javascripts/syllabus.js index f65ddf11b..1b2a18a41 100644 --- a/public/javascripts/syllabus.js +++ b/public/javascripts/syllabus.js @@ -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"); diff --git a/public/stylesheets/syllabus.css b/public/stylesheets/syllabus.css index 88c8cebbf..6218f52e0 100644 --- a/public/stylesheets/syllabus.css +++ b/public/stylesheets/syllabus.css @@ -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;} @@ -153,4 +153,6 @@ a.course-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap a:hover.course-title{ color:#269ac9;} /*新建页面*/ -.name_input{ border:1px solid #64bdd9; height:16px; width:310px; background:#fff; margin-bottom:10px; padding:5px;} \ No newline at end of file +.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;}