diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 2e3612b94..bc764d034 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -45,9 +45,62 @@ class AdminController < ApplicationController
render :action => "projects", :layout => false if request.xhr?
end
- def courses
+ def syllabuses
@name = params[:name]
- @courses = Course.like(@name).order('created_at desc')
+ @syllabuses = Syllabus.like(@name).order('created_at desc')
+ @syllabuses = paginateHelper @syllabuses,30
+ @page = (params['page'] || 1).to_i - 1
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #为班级选择课程
+ def select_course_syllabus
+ @flag = false
+ if params[:syllabus_id] && params[:course_id]
+ course = Course.where("id = #{params[:course_id].to_i}").first
+ unless course.nil?
+ course.update_attribute('syllabus_id', params[:syllabus_id].to_i)
+ @flag = true
+ end
+ end
+ if @flag
+ render :text=> "succ"
+ else
+ render :text=>'fail'
+ end
+ end
+
+ #新建课程
+ def create_syllabus
+ if params[:course_id]
+ course = Course.where("id = #{params[:course_id]}").first
+ if course
+ @user = course.teacher
+ syllabus = Syllabus.new
+ syllabus.update_attributes(:title => params[:title], :eng_name => params[:eng_name], :user_id => @user.id)
+ syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content
+ if syllabus.save
+ course.update_attribute('syllabus_id', syllabus.id)
+ @flag = params[:flag].to_i
+ @course = course
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+ end
+ end
+
+ def courses
+ @name = params[:name].to_s.strip.downcase
+ if @name && @name != ""
+ @courses = Course.select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)}
+ @courses = @courses.sort{|x, y| y.created_at <=> x.created_at}
+ else
+ @courses = Course.order('created_at desc')
+ end
@courses = paginateHelper @courses,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
@@ -55,6 +108,33 @@ class AdminController < ApplicationController
end
end
+ #未配置班级列表
+ def non_syllabus_courses
+ @name = params[:name].to_s.strip.downcase
+ if @name && @name != ""
+ @courses = Course.where("syllabus_id is null").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)}
+ @courses = @courses.sort{|x, y| y.created_at <=> x.created_at}
+ else
+ @courses = Course.where("syllabus_id is null").order('created_at desc')
+ end
+ @courses = paginateHelper @courses,30
+ @page = (params['page'] || 1).to_i - 1
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #修改课程名称
+ def update_course_name
+ @course = Course.where("id = #{params[:course_id].to_i}").first
+ unless @course.nil?
+ @course.update_attribute("name", params[:name])
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
#管理员界面精品课程列表
def excellent_courses
@courses = Course.where("is_excellent =? or excellent_option =?", 1, 1 )
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index cb8b06a8f..e4fa452f5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3322,3 +3322,21 @@ def get_group_member_names work
end
result
end
+
+def course_syllabus_option user
+ syllabuses = user.syllabuses
+ type = []
+ option1 = []
+ option1 << "请选择课程"
+ option1 << 0
+ type << option1
+ unless syllabuses.empty?
+ syllabuses.each do |syllabus|
+ option = []
+ option << syllabus.title
+ option << syllabus.id
+ type << option
+ end
+ end
+ type
+end
\ No newline at end of file
diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb
index 5e368f341..58e822ffa 100644
--- a/app/models/syllabus.rb
+++ b/app/models/syllabus.rb
@@ -9,9 +9,18 @@ class Syllabus < ActiveRecord::Base
belongs_to :user
has_many :courses
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
- attr_accessible :description, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course
+ attr_accessible :user_id, :description, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course
safe_attributes 'title', 'description', 'eng_name', 'syllabus_type', 'credit', 'hours', 'theory_hours', 'practice_hours', 'credit', 'applicable_major', 'pre_course'
+ scope :like, lambda {|arg|
+ if arg.blank?
+ where(nil)
+ else
+ pattern = "%#{arg.to_s.strip.downcase}%"
+ where(" LOWER(title) LIKE :p ", :p => pattern)
+ end
+ }
+
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::SYLLABUS
end
diff --git a/app/views/admin/_courselist_detail_tr.html.erb b/app/views/admin/_courselist_detail_tr.html.erb
new file mode 100644
index 000000000..07486faa3
--- /dev/null
+++ b/app/views/admin/_courselist_detail_tr.html.erb
@@ -0,0 +1,30 @@
+
+ <%= course.id %>
+
+
+
+ <%= link_to(course.name, course_path(course.id)) %>
+
+
+
+ <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
+
+
+ <%= course.class_period %>
+
+
+ <%= checked_image course.is_public? %>
+
+
+ <%= format_date(course.created_at) %>
+
+
+ <%= course.updated_at.strftime('%Y-%m-%d %H:%M:%S') %>
+
+
+ <%= select_tag :syllabus_id,options_for_select(course_syllabus_option(course.teacher),course.syllabus_id), {:id=>"new_syllabus_id_#{course.id}", :class=>"course_syllabus_input", :onchange=>"select_syllabus(#{course.id});"}%>
+
+
+ 新建课程
+ <%#= link_to "新建课程", admin_create_syllabus_path%>
+
\ No newline at end of file
diff --git a/app/views/admin/_tab_syllabuses_courses.erb b/app/views/admin/_tab_syllabuses_courses.erb
new file mode 100644
index 000000000..7530b3af7
--- /dev/null
+++ b/app/views/admin/_tab_syllabuses_courses.erb
@@ -0,0 +1,7 @@
+
+
+ <%= link_to '课程列表', {:action => 'syllabuses'}, class: "#{current_page?(all_syllabuses_path)? 'selected' : nil }" %>
+ <%= link_to '全部班级列表', {:action => 'courses'}, class: "#{current_page?(all_courses_path)? 'selected' : nil }" %>
+ <%= link_to '未配置班级列表', {:action => 'non_syllabus_courses'}, class: "#{current_page?(non_syllabus_courses_path)? 'selected' : nil }" %>
+
+
\ No newline at end of file
diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb
index 65e442a3e..11fb1973f 100644
--- a/app/views/admin/courses.html.erb
+++ b/app/views/admin/courses.html.erb
@@ -5,15 +5,20 @@
<%=l(:label_course_all)%>
+<%= render 'tab_syllabuses_courses' %>
+
+
+ 班级列表
+
<%= form_tag({}, :method => :get) do %>
- 课程:
+ 班级:
- <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
+ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '班级、老师名称' %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
- <%= link_to l(:button_clear), {:controller => 'admin', :action => 'courses'},:remote => true, :class => 'icon icon-reload' %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'courses'}, :class => 'icon icon-reload' %>
<% end %>
@@ -26,51 +31,35 @@
序号
- 课程
+ 班级
主讲老师
-
+
学时
-
+
<%=l(:field_is_public)%>
-
+
<%=l(:field_created_on)%>
-
+
动态时间
+
+ 课程
+
+
+
+
<% @courses.each do |course| %>
- ">
-
- <%= course.id %>
-
-
-
- <%= link_to(course.name, course_path(course.id)) %>
-
-
-
- <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
-
-
- <%= course.class_period %>
-
-
- <%= checked_image course.is_public? %>
-
-
- <%= format_date(course.created_at) %>
-
-
- <%= course.updated_at.strftime('%Y-%m-%d %H:%M:%S') %>
-
+ " id="course_<%=course.id %>">
+ <%=render :partial => 'courselist_detail_tr', :locals => {:course => course} %>
<% end %>
@@ -81,4 +70,19 @@
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
+
<% html_title(l(:label_course_all)) -%>
diff --git a/app/views/admin/create_syllabus.js.erb b/app/views/admin/create_syllabus.js.erb
new file mode 100644
index 000000000..ac37abd78
--- /dev/null
+++ b/app/views/admin/create_syllabus.js.erb
@@ -0,0 +1,10 @@
+hideModal();
+<%courses = Course.where("tea_id = #{@user.id}") %>
+<% unless courses.empty? %>
+ <% courses.each do |course|%>
+ $("#course_<%=course.id %>").html("<%=escape_javascript(render :partial => 'courselist_detail_tr', :locals => {:course => course}) %>");
+ <% end %>
+<% end %>
+<% if @flag == 1 %>
+ $("#course_<%=@course.id %>").html("");
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb
index c107713a0..0418ebf30 100644
--- a/app/views/admin/excellent_courses.html.erb
+++ b/app/views/admin/excellent_courses.html.erb
@@ -16,7 +16,7 @@
序号
- 课程名
+ 班级名
主讲老师
diff --git a/app/views/admin/non_syllabus_courses.html.erb b/app/views/admin/non_syllabus_courses.html.erb
new file mode 100644
index 000000000..6c3cbec10
--- /dev/null
+++ b/app/views/admin/non_syllabus_courses.html.erb
@@ -0,0 +1,164 @@
+
+ <%= link_to l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
+
+
+
+ 未配置班级列表
+
+<%= render 'tab_syllabuses_courses' %>
+
+
+ 未配置班级列表
+
+
+<%= form_tag({}, :method => :get) do %>
+
+
+ 班级:
+
+ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '班级、老师名称' %>
+ <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'non_syllabus_courses'}, :class => 'icon icon-reload' %>
+
+<% end %>
+
+
+
+
+
+
+
+<% html_title(l(:label_course_all)) -%>
diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb
new file mode 100644
index 000000000..1066ac3ef
--- /dev/null
+++ b/app/views/admin/syllabuses.html.erb
@@ -0,0 +1,142 @@
+
+ 课程列表
+
+<%= render 'tab_syllabuses_courses' %>
+
+
+ 课程列表
+
+
+<%= form_tag({}, :method => :get) do %>
+
+
+ 课程:
+
+ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
+ <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'syllabuses'}, :class => 'icon icon-reload' %>
+
+<% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/update_course_name.js.erb b/app/views/admin/update_course_name.js.erb
new file mode 100644
index 000000000..2da524b5b
--- /dev/null
+++ b/app/views/admin/update_course_name.js.erb
@@ -0,0 +1 @@
+$("#rename_course_name_<%=@course.id %>").html("<%=@course.name %>");
\ No newline at end of file
diff --git a/app/views/layouts/base_admin.html.erb b/app/views/layouts/base_admin.html.erb
index cff80a15d..81cc2df9d 100644
--- a/app/views/layouts/base_admin.html.erb
+++ b/app/views/layouts/base_admin.html.erb
@@ -19,6 +19,10 @@
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
+
+
diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml
index 1aa1ea666..29d6b236c 100644
--- a/config/locales/courses/zh.yml
+++ b/config/locales/courses/zh.yml
@@ -12,7 +12,7 @@ zh:
#
label_course_join_student: 加入班级
label_course_exit_student: 退出班级
- label_course_new: 新建课程
+ label_course_new: 新建班级
label_course_name: 课程名称
label_homework: 作业
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index fc3e39980..0220cd11c 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -482,9 +482,10 @@ zh:
label_show_contest: 显示竞赛
#by young
label_requirement: 需求
- label_new_course: 课程列表
- label_course_all: 课程列表
- label_excellent_courses_list: 精品课程列表
+ label_new_course: 班级列表
+ label_course_all: 班级列表
+ label_syllabus_all: 课程列表
+ label_excellent_courses_list: 精品班级列表
label_course_resource_list: 班级资源列表
label_project_resource_list: 項目资源列表
label_teacher_all: 所有教师
@@ -1367,7 +1368,7 @@ zh:
label_bid_reason_homework: 请输入作业提交说明!
label_create_new_projects: 创建项目
label_call_for_bids: 发布需求
- label_create_course: 创建课程
+ label_create_course: 创建班级
label_milestone: 里程碑
label_features: 特性
@@ -1488,7 +1489,7 @@ zh:
label_user_project: 项目
- label_user_course: 课程
+ label_user_course: 班级
label_user_homework: 作业
label_bid_if_agreement: 如果喜欢我,请点击我
@@ -1542,7 +1543,7 @@ zh:
label_teacher_work_unit: 教师单位
label_course_time: 课程年度
label_i_new_activity: 有了新活动在
- label_choose_course: 选择课程
+ label_choose_course: 选择班级
button_submit_homework: 提交作业
button_submit_bid: 参与竞标
label_requirement_from: 需求来源
@@ -1596,9 +1597,9 @@ zh:
#end
- label_joined_course: 参加的课程
- label_created_course: 创建的课程
- label_course: 课程
+ label_joined_course: 参加的班级
+ label_created_course: 创建的班级
+ label_course: 班级
label_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。)
diff --git a/config/routes.rb b/config/routes.rb
index 4465c9e1b..5717325e1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1027,7 +1027,10 @@ RedmineApp::Application.routes.draw do
match 'admin', :to => 'admin#index', :via => :get
match 'admin/projects', :via => :get
- get 'admin/courses'
+ get 'admin/courses', as: :all_courses
+ get 'admin/syllabuses', as: :all_syllabuses
+ get 'admin/non_syllabus_courses', as: :non_syllabus_courses
+ post 'admin/update_course_name'
get 'admin/excellent_courses', as: :excellent_courses
get 'admin/excellent_all_courses', as: :excellent_all_courses
match 'admin/set_excellent_course/:id', :to => 'admin#set_excellent_course'
@@ -1060,6 +1063,8 @@ RedmineApp::Application.routes.draw do
get 'admin/homework'
get 'admin/apply_for_homework'
get 'admin/code_work_tests'
+ post 'admin/select_course_syllabus'
+ post 'admin/create_syllabus'
resources :auth_sources do
member do
diff --git a/lib/redmine.rb b/lib/redmine.rb
index c0aa658ae..cfd8b6824 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -367,7 +367,7 @@ end
Redmine::MenuManager.map :admin_menu do |menu|
menu.push :organization, {:controller => 'admin', :action => 'organization'}, :caption => :label_organization_list
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
- menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all
+ menu.push :syllabuses, {:controller => 'admin', :action => 'syllabuses'}, :caption => :label_course_all
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message
menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 525a1fb1a..da833fe47 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1589,3 +1589,71 @@ function expand_course_list(id, target, btnid, count) {
}
}
+function regex_syllabus_name() {
+ var name = $.trim($("#new_syllabus_name").val());
+ if(name.length < 2)
+ {
+ $("#new_syllabus_name_notice").show();
+ return false;
+ }
+ else
+ {
+ $("#new_syllabus_name_notice").hide();
+ return true;
+ }
+}
+
+function alert_new_syllabus(course_id, flag){
+ htmlvalue = "
";
+ pop_up_box(htmlvalue,600,30,50);
+}
+
+function admin_new_syllabus(course_id, flag){
+ if(regex_syllabus_name()) {
+ $.ajax({
+ type: "post",
+ url: "/admin/create_syllabus",
+ data: {course_id: course_id,
+ title: $("#new_syllabus_name").val(),
+ eng_name: $("#new_syllabus_eng_name").val(),
+ flag: flag},
+ success: function (data) {
+ }
+ });
+ hideModal();
+ }
+}
+
+//执行修改courseName方法
+function updateCourseName(){
+ if(isdb){
+ isdb = false;
+ if($("#renameCourseName").val() == tagName){ //如果值一样,则恢复原来的状态
+ ele.parent().css("border","");
+ ele.parent().html(tagNameHtml);
+ }
+ else{
+ $.post(
+ '<%= admin_update_course_name_path %>',
+ {"course_id": tagId, "name": $("#renameCourseName").val().trim()}
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 8215f3aa1..0e60f01c9 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -224,20 +224,6 @@ function submit_new_syllabus()
}
}
-function regex_syllabus_name() {
- var name = $.trim($("#new_syllabus_name").val());
- if(name.length < 2)
- {
- $("#new_syllabus_name_notice").show();
- return false;
- }
- else
- {
- $("#new_syllabus_name_notice").hide();
- return true;
- }
-}
-
//课程讨论区
function regexTopicSubject() {
var name = $("#message_subject").val();
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 3764ceb04..112f8224b 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1409,6 +1409,7 @@ table td {padding:2px;}
table p {margin:0;}
.odd {background-color:#f6f7f8;}
.even {background-color: #fff;}
+.odd_grey {background-color: #b4b4b4}
a.sort { padding-right: 16px; background-position: 100% 50%; background-repeat: no-repeat; }
a.sort.asc { background-image: url(../images/sort_asc.png); }
@@ -2847,4 +2848,10 @@ img.school_avatar {
}
.admin_message_warn{font-size: 12px;color: red;}
-a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;}
\ No newline at end of file
+a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;}
+
+.course_syllabus_input{width:120px;}
+.name_input{ border:1px solid #64bdd9; height:16px; width:310px; background:#fff; margin-bottom:10px; padding:5px;}
+a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; 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.Blue-btn{ background:#3598db; color:#fff;}
+.c_white {color:#fff;}
\ No newline at end of file