结束日期过后,课堂进入归档状态,只能在历史课堂中查看
+结束日期过后,课堂进入<%= link_to '归档状态', courses_path(:select => "end", :is_end => 1),:target => '_blank', :class => 'color-orange05' %>,只能在历史课堂中查看
From bb9fb39396dda6a8a7fc03222a4f6eaa8f692f00 Mon Sep 17 00:00:00 2001 From: XuCheng642 <287102909@qq.com> Date: Fri, 1 Sep 2017 19:37:09 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/department_controller.rb | 22 ++++ app/controllers/managements_controller.rb | 124 ++++++++++++++---- app/controllers/school_controller.rb | 21 ++- app/models/apply_add_department.rb | 15 ++- app/views/challenges/_skill_form.html.erb | 2 +- app/views/courses/new.html.erb | 2 +- app/views/department/destroy.js.erb | 6 + app/views/layouts/base_management.html.erb | 4 +- .../managements/_all_department.html.erb | 2 +- app/views/managements/_all_schools.html.erb | 2 +- .../_classroom_classment_list.html.erb | 6 +- .../managements/_create_department.html.erb | 99 ++++++++++++++ .../managements/_departments_list.html.erb | 33 +++-- .../_departments_part_list.html.erb | 2 +- .../managements/_update_department.html.erb | 52 ++++++++ .../_update_department_form.html.erb | 2 +- .../_update_department_school.html.erb | 24 ++++ .../managements/_update_school_form.html.erb | 2 +- app/views/managements/add_department.js.erb | 1 + app/views/managements/all_department.js.erb | 2 +- app/views/managements/all_schools.js.erb | 2 +- .../managements/create_departments.js.erb | 2 + app/views/managements/departments.html.erb | 2 +- .../managements/trial_authorization.html.erb | 2 +- .../managements/update_department.js.erb | 6 + app/views/school/destroy.js.erb | 5 + .../users/_user_experience_content.html.erb | 74 +++++------ app/views/users/growth_record.html.erb | 2 +- app/views/users/show.html.erb | 6 +- config/routes.rb | 4 + 30 files changed, 426 insertions(+), 102 deletions(-) create mode 100644 app/views/department/destroy.js.erb create mode 100644 app/views/managements/_create_department.html.erb create mode 100644 app/views/managements/_update_department.html.erb create mode 100644 app/views/managements/_update_department_school.html.erb create mode 100644 app/views/managements/add_department.js.erb create mode 100644 app/views/managements/create_departments.js.erb create mode 100644 app/views/managements/update_department.js.erb create mode 100644 app/views/school/destroy.js.erb diff --git a/app/controllers/department_controller.rb b/app/controllers/department_controller.rb index 7e9438843..eeb4a82ba 100644 --- a/app/controllers/department_controller.rb +++ b/app/controllers/department_controller.rb @@ -1,5 +1,7 @@ class DepartmentController < ApplicationController + before_filter :find_department, :only => [:destroy] + #根据部门名字或者拼音来查询 def on_search school = School.find params[:school_id] @@ -95,4 +97,24 @@ class DepartmentController < ApplicationController render :json =>status end + + def destroy + if @department + if UserExtensions.where(:department_id => @department.id).count == 0 + ApplyAddDepartment.where(:department_id=>@department.id).update_all(:status => 2) + @apply_dep = ApplyAddDepartment.where(:department_id=>@department.id).first + @department.destroy + end + respond_to do |format| + format.js + end + end + end + + private + def find_department + @department = Department.find params[:id] + rescue ActiveRecord::RecordNotFound + render_404 + end end diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 5afefc51c..ca759ce77 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -136,7 +136,7 @@ class ManagementsController < ApplicationController end if params[:support_shixuns] - @major = @major.where(:support_shixuns => params[:support_shixuns].to_i,:major_level=> 1) + @major = @major.where(:support_shixuns => params[:support_shixuns].to_i,:major_level=>2) end @major = @major.order("created_at #{@sx_order}") @@ -219,7 +219,7 @@ end @menu_type = 6 @sub_type = 2 @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order] - @department =Department.where("0=0") + @department = ApplyAddDepartment.where(:status => 1) search=params[:search] if search.blank? @department = @department @@ -239,6 +239,72 @@ end end end + # 新增 + def create_departments + respond_to do |format| + format.js + end + end + + def add_department + department = Department.where(:school_id => params[:school], :name => params[:department]).first + if department.nil? + department = Department.create(:school_id => params[:school],:name => params[:department]) + ApplyAddDepartment.create(:school_id => params[:school], + :status => 1, + :name => params[:department], + :department_id => department.id, + :user_id => User.current.id); + end + respond_to do |format| + format.js + end + #redirect_to departments_managements_path + end + + # 修改单位部门列表 + def update_department + dep = Department.find params[:department_id] + apply_schools = ApplyAddDepartment.where(:status => 1, :school_id => dep.school_id) + apply_school_ids = apply_schools.empty? ? "(-1)" : "(" + apply_schools.map{|sc| sc.department_id}.join(',') + ")" + @edit_id = params[:department_id] + @search = params[:search] + if !params[:search].nil? + search = "%#{params[:search].to_s.strip.downcase}%" + @departments = Department.where("id in #{apply_school_ids} and #{Department.table_name}.name like :p", :p => search) + #@schools = School.all + else + @departments = Department.where("id in #{apply_school_ids}") + end + respond_to do |format| + format.js + end + end + + def edit_departments_school + begin + dep = Department.find(params[:department_id]); + alter_dep = Department.find(params[:alter_dep_id]); + apply_dep = ApplyAddDepartment.where(:department_id => params[:alter_dep_id]) + if dep && alter_dep + # users = UserExtensions.where("department_id = #{dep.id}") + # users.update_all(:department_id => params[:alter_dep_id]) + # dep.destroy + # apply_dep.update_all(:status => 2) + # ApplyAddDepartment.where(:department_id =>params[:departments]).update_all(:department_id=>department_id) + # users = UserExtensions.where("department_id = #{alt_dep.department_id}") + # users.update_all(:department_id => department.id) + apply_dep.destroy_all; + users = UserExtensions.where(:department_id => params[:alter_dep_id]) + users.update_all(:department_id => dep.id) + alter_dep.destroy + end + rescue Exception => e + puts e + end + redirect_to departments_managements_path + end + # 单位列表 def departments_part @menu_type = 6 @@ -324,23 +390,24 @@ end # 部门修改 def all_department - apply_department = ApplyAddDepartment.where("status = 0") + @edit_id = params[:department_id] + @search = params[:search] + apply_department = ApplyAddDepartment.where(:status => 1) apply_department_ids = apply_department.empty? ? "(-1)" : "(" + apply_department.map{|sc| sc.department_id}.join(',') + ")" if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" - @department = Department.where("id not in #{apply_department_ids} and #{Department.table_name}.name like :p", :p => search) + @department = Department.where("id in #{apply_department_ids} and #{Department.table_name}.name like :p", :p => search) #@schools = School.all else #@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)} - @department = Department.where("id not in #{apply_department_ids}") + @department = Department.where("id in #{apply_department_ids}") end - @edit_id = params[:department_id] - @search = params[:search] respond_to do |format| format.js end # redirect_to unit_managements_path end + # 修改 def edit_applied_department aas =ApplyAddDepartment.find(params[:applied_id]) @@ -349,19 +416,19 @@ end department =Department.find params[:department_id] begin #更新消息表的status - applied_message_id = aas.department_id - applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddDepartment") - applied_message.update_all(:status => 4) - aas.update_attribute(:status, 2) - AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddDepartment", :name =>department[0].name ) - users = UserExtensions.where("department_id = #{aas.department_id}") - users.update_all(:department_id => department.id) if aas.department_id != department.id.to_i + applied_message_id = aas.department_id + applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddDepartment") + applied_message.update_all(:status => 4) + aas.update_attribute(:status, 2) + AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddDepartment", :name =>department.name ) + users = UserExtensions.where("department_id = #{aas.department_id}") + users.update_all(:department_id => department.id) aas.department.destroy + ApplyAddDepartment.where(:department_id => aas.department_id).update_all(:department_id => department.id) + Department.where(:department_id => aas.department_id).destroy_all + aas.destroy_all end - ApplyAddDepartment.where(:department_id => aas.department_id).update_all(:department_id => department.id) - Department.where(:department_id => aas.department_id).update_all(:department_id => department.id) - aas.update_attribute(:department_id, department.id) rescue Exception => e puts e end @@ -463,19 +530,20 @@ end school = School.find params[:school_id] begin #更新消息表的status - applied_message_id = aas.school_id - applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") - applied_message.update_all(:status => 4) - aas.update_attribute(:status, 2) - AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name ) - users = UserExtensions.where("school_id = #{aas.school_id}") - users.update_all(:school_id => school.id) if aas.school_id != school.id.to_i + applied_message_id = aas.school_id + applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") + applied_message.update_all(:status => 4) + aas.update_attribute(:status, 2) + AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school.name ) + users = UserExtensions.where("school_id = #{aas.school_id}") + users.update_all(:school_id => school.id) + + ApplyAddDepartment.where(:school_id => aas.school_id).update_all(:school_id => school.id) + Department.where(:school_id => aas.school_id).update_all(:school_id => school.id) aas.school.destroy + aas.update_attribute(:school_id, school.id) end - ApplyAddDepartment.where(:school_id => aas.school_id).update_all(:school_id => school.id) - Department.where(:school_id => aas.school_id).update_all(:school_id => school.id) - aas.update_attribute(:school_id, school.id) rescue Exception => e puts e end @@ -539,7 +607,7 @@ end end end - # 班级列表 + # 课堂列表 def classroom_classment @menu_type = 2 @sub_type = 2 diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index ef053bb16..334c880e2 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -1,7 +1,7 @@ class SchoolController < ApplicationController layout 'course_base' before_filter :require_admin, :only => :upload_logo - + before_filter :find_school, :only => [:destroy] def upload uploaded_io = params[:logo] school_id ||= params[:id] @@ -283,4 +283,23 @@ class SchoolController < ApplicationController render :json=>{:status=>status,:id=>params[:id],:province=>province,:city=>city} end + + def destroy + if @school + if UserExtensions.where(:school_id => @school.id).count == 0 + School.where(:id=>@school.id).destroy_all + @school.destroy + end + respond_to do |format| + format.js + end + end + end + + private + def find_school + @school = School.find params[:id] + rescue ActiveRecord::RecordNotFound + render_404 + end end diff --git a/app/models/apply_add_department.rb b/app/models/apply_add_department.rb index 4b6a984d0..5ea5c00ec 100644 --- a/app/models/apply_add_department.rb +++ b/app/models/apply_add_department.rb @@ -1,7 +1,8 @@ -class ApplyAddDepartment < ActiveRecord::Base - belongs_to :school - belongs_to :user - attr_accessible :name, :remarks, :status, :school_id, :user_id - has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied - belongs_to :department -end +class ApplyAddDepartment < ActiveRecord::Base + belongs_to :school + belongs_to :user + attr_accessible :name, :remarks, :status, :school_id, :user_id, :department_id + has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied + belongs_to :department + # status: 0表示未批准; status:1表示已批准; status: 2表示已更改; status: 3表示已拒绝; status: 4表示已更改后废除的部门 +end diff --git a/app/views/challenges/_skill_form.html.erb b/app/views/challenges/_skill_form.html.erb index 8540374d9..11c0977f4 100644 --- a/app/views/challenges/_skill_form.html.erb +++ b/app/views/challenges/_skill_form.html.erb @@ -11,7 +11,7 @@ <% end %> <% end %> -
diff --git a/app/views/department/destroy.js.erb b/app/views/department/destroy.js.erb new file mode 100644 index 000000000..4c853a4b0 --- /dev/null +++ b/app/views/department/destroy.js.erb @@ -0,0 +1,6 @@ +console.log(111); +for(var i=0; i<$("#apply_add_department_<%= @apply_dep.id %>").nextAll().length; i++){ + var index = parseInt($($("#apply_add_department_<%= @apply_dep.id %>").nextAll()[i]).children(":first").html()); + $($("#apply_add_department_<%= @apply_dep.id %>").nextAll()[i]).children(":first").html(index - 1); +} +$("#apply_add_department_<%= @apply_dep.id %>").remove(); \ No newline at end of file diff --git a/app/views/layouts/base_management.html.erb b/app/views/layouts/base_management.html.erb index bf1f662a5..da4b7ed0d 100644 --- a/app/views/layouts/base_management.html.erb +++ b/app/views/layouts/base_management.html.erb @@ -26,7 +26,7 @@ <% case @menu_type %> <% when 2 %> - <%= @sub_type == 1 ? "课程列表" : "班级列表" %> + <%= @sub_type == 1 ? "课程列表" : "课堂列表" %> <% when 3 %> <%= @sub_type == 1 ? "实训列表" :(@sub_type == 2 ? "已发布的实训": (@sub_type == 3 ? "已关闭的实训": "镜像管理")) %> <% when 4 %> @@ -55,7 +55,7 @@
- 您还没有获得过经验值哦~
+ <% if @user_experiences.blank? %> +
+ 您还没有获得过经验值哦~
+| 操作 | +变更 | +详情 | +操作时间 | +
|---|---|---|---|
| 闯关 | ++ <%= exp.score %> | + <% game = Game.where(:id => exp.container_id).first %> +<%= game ? "通过实训“#{game.challenge.shixun.name}”的第#{game.challenge.position}关获得的奖励" : "--" %> | +<%= format_time exp.created_at %> | +
+
<% update_visiti_count @user %> <%= @user.visits.to_i %> 次访问 @@ -139,12 +139,14 @@ <% else %>
+
<%= @user.visits.to_i %> 次访问
+ 经验值<%= link_to @user.experience %> + 金币<%= link_to @user.grade %> 给TA留言 <% if(@user.watched_by?(User.current)) %> <%= link_to "已关注", diff --git a/config/routes.rb b/config/routes.rb index b2ef63a14..8fea46036 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -222,6 +222,10 @@ RedmineApp::Application.routes.draw do delete 'delete_applied_schools' match 'new_major', :via => [:get, :post] post 'insert_major' + match 'update_department',:via => [:get, :post] + post 'edit_departments_school' + get 'create_departments' + post 'add_department' end end # Enable Grack support From 57315b6a4b8f6d17337c929fd13c98a7ae710f4e Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 1 Sep 2017 19:50:16 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E8=BE=B9=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_bank/_new_shixun_homework_list.html.erb | 2 +- app/views/homework_common/_new_shixun_homework_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_bank/_new_shixun_homework_list.html.erb b/app/views/homework_bank/_new_shixun_homework_list.html.erb index 327b58b7d..8b542540d 100644 --- a/app/views/homework_bank/_new_shixun_homework_list.html.erb +++ b/app/views/homework_bank/_new_shixun_homework_list.html.erb @@ -10,7 +10,7 @@
<% @shixuns.each do |shixun| %>- 给TA留言 - 经验值<%= link_to @user.experience %> - 金币<%= link_to @user.grade %> + 给TA留言 <% if(@user.watched_by?(User.current)) %> <%= link_to "已关注", watch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id), @@ -165,6 +163,8 @@ :remote => "true", :title => "添加关注" %> <% end %> + 经验值 <%= @user.experience %> + 金币<%= @user.grade %>
From 4c8c56e3cebd7538da74991c98910c07d3d2306b Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 1 Sep 2017 21:07:09 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=E9=98=B4=E5=BD=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_edu_user_watch_fan_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_edu_user_watch_fan_list.html.erb b/app/views/users/_edu_user_watch_fan_list.html.erb index a02f91809..236878007 100644 --- a/app/views/users/_edu_user_watch_fan_list.html.erb +++ b/app/views/users/_edu_user_watch_fan_list.html.erb @@ -33,7 +33,7 @@注意:1、课堂名称 = 课程名称 + 学期信息
+正确示例:数据结构2016秋季A班
+错误示例:数据结构A班
+2、本学期包含多个班级的课程,只需创建一个课堂
+创建课堂后,可以在课堂内部建立不同的分班
+结束日期过后,课堂进入<%= link_to '归档状态', courses_path(:is_over => 1),:target => '_blank', :class => 'color-orange05' %>,只能在历史课堂中查看
+结束日期过后,课堂进入归档状态<%#= link_to '归档状态', courses_path(:is_over => 1),:target => '_blank', :class => 'color-orange05' %>,只能在历史课堂中查看
<%= image_tag(url_to_avatar(user), :width =>"80", :height => "80", :class => "bor-radius-all", :alt=>"头像") %>
<%= user.try(:show_name) %>
-<%= user.school_name + user.identity %>
+<%= user.school_name %>
" + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
") ) + "
" + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/\s+/g, "") ) + "
" + (test_sets[i].actual_output == null ? "空" : test_sets[i].actual_output.replace(/\r\n/g, "
")) + "
" + (test_sets[i].actual_output == null ? "空" : ((had_passed_testsests_error_count != "0") ? test_sets[i].actual_output.replace(/\r\n/g, "
") : test_sets[i].output.replace(/\r\n/g, "
").replace(/\s+/g, "")) ) + "
注意:1、课堂名称 = 课程名称 + 学期信息
-正确示例:数据结构2016秋季A班
-错误示例:数据结构A班
-2、本学期包含多个班级的课程,只需创建一个课堂
-创建课堂后,可以在课堂内部建立不同的分班
+注意:1、课堂名称 = 课程名称 + 学期信息 + 其它
+正确示例:数据结构2016秋季班级
+错误示例:数据结构班级
+2、如果本学期包含多个班级,只需创建一个课堂
+然后在课堂内部建立不同的分班
" + (test_sets[i].actual_output == null ? "空" : ((had_passed_testsests_error_count != "0") ? test_sets[i].actual_output.replace(/\r\n/g, "
") : test_sets[i].output.replace(/\r\n/g, "
").replace(/\s+/g, "")) ) + "
" + (test_sets[i].actual_output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/\s+/g, "")) + "
" + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/\s+/g, "") ) + "
" + ( test_sets[i].output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/ /g, "") ) + "
" + (test_sets[i].actual_output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/\s+/g, "")) + "
" + (test_sets[i].actual_output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/ /g, "")) + "
" + (test_sets[i].actual_output == null ? "空" : test_sets[i].output.replace(/\r\n/g, "
").replace(/ /g, "")) + "
" + (test_sets[i].actual_output == null ? "空" : test_sets[i].actual_output.replace(/\r\n/g, "
").replace(/ /g, "")) + "