diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9a42aae4..95bf2f58 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,8 +1175,46 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school) + @schools = School.where("partner_id IS NULL").all + @page = (params['page'] || 1).to_i + @schools_count = @schools.count + @limit = 10 + @is_remote = true + @schools_pages = Paginator.new @schools_count, @limit, @page + @offset ||=@schools_pages.offset + @schools = paginateHelper @schools, @limit + end + + def all_partners + @schools = School.where("partner_id IS NULL").all + @page = (params['page'] || 1).to_i + @schools_count = @schools.count + @limit = 10 + @is_remote = true + @schools_pages = Paginator.new @schools_count, @limit, @page + @offset ||=@schools_pages.offset + @schools = paginateHelper @schools, @limit + render :json => @schools + end + + + def add_partner + school_ids = params[:ids] + if school_ids.count > 0 + print school_ids + school_ids.each do |s| + school = School.where("id = ?",s).first + @partner = Partner.new(name: school.name) + @partner.save + school.partner_id = @partner.id + school.save + end + render :json => {status: 1, message: "创建成功!"} + end end + + # 删除部门管理员 def delete_depart_member DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 78fb4a63..367b3e99 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -9,6 +9,7 @@ class PollController < ApplicationController before_filter :require_login, :only => [:student_poll_list, :show] include PollHelper include ApplicationHelper + def index if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 @@ -18,13 +19,13 @@ class PollController < ApplicationController if @is_teacher polls = @course.polls.order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") - elsif User.current.member_of_course?(@course) + elsif User.current.member_of_course?(@course) # 课堂成员显示为发布的和已发布的 member = @course.members.where(:user_id => User.current.id).first if member.try(:course_group_id).to_i == 0 polls = @course.polls.where("publish_time <= '#{Time.now}' and unified_setting = 1").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") - else + else # 已分班的成员 not_poll_ids = @course.poll_group_settings.where("course_group_id = #{member.try(:course_group_id)} and (publish_time > '#{Time.now}' or publish_time is null)") - not_poll_ids = not_poll_ids.blank? ? "(-1)" : "(" + not_poll_ids.map(&:poll_id).join(",") + ")" + not_poll_ids = not_poll_ids.blank? ? "(-1)" : "(" + not_poll_ids.map(&:poll_id).join(",") + ")" # 已分班,但是成员不再 polls = @course.polls.where("publish_time <= '#{Time.now}' and id not in #{not_poll_ids}").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") end else @@ -414,7 +415,6 @@ class PollController < ApplicationController def update_poll_question @poll_question = PollQuestion.find params[:poll_question] @poll = @poll_question.poll - @poll_question.is_necessary = params[:is_necessary] == "1" ? 1 : 0 @poll_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] @poll_question.max_choices = params[:max_choices].to_i || 0 @poll_question.min_choices = params[:min_choices].to_i || 0 diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 411fc3c3..1ac26aa6 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -20,11 +20,11 @@ module PollHelper def un_commit_num poll course = poll.course - member = course.members.where(:user_id => User.current.id).first - poll_users = poll.poll_users - student_count = course.student.count + member = course.members.where(:user_id => User.current.id).first ## 当前用户是否为课堂成员 + poll_users = poll.poll_users # 问卷的全部用户,包含已回答的/为回答,但是浏览的 + student_count = course.student.count # 课堂的学生数 if member.present? && member.teacher_course_groups.count > 0 - group_students = course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) + group_students = course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) ## 统计当前用户所在班级的全部学生 student_count = group_students.size poll_users = poll_users.where(:user_id => group_students) end diff --git a/app/models/customer.rb b/app/models/customer.rb index dab10ac9..bbfe45c6 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,5 @@ class Customer < ActiveRecord::Base belongs_to :partner - has_one :scholl + has_one :school has_many :users end diff --git a/app/views/courses/index.js.erb b/app/views/courses/index.js.erb index 7ed24fff..f211e3ae 100644 --- a/app/views/courses/index.js.erb +++ b/app/views/courses/index.js.erb @@ -1 +1 @@ -$("#intelligence_course_list").html("<%= j(render :partial => "courses/courseList") %>"); \ No newline at end of file +$("#intelligence_course_list").html("<%= j(render :partial => "courses/courseList") %>"); diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index 1001d32c..e18890dc 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -1,7 +1,7 @@
单位 地区
- - - - - - - 湖南 -
-- - - - - - - 湖南 -
-- - - - - - - 湖南 -
++ +
" + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " "+array["school"]["province"]+"" + + "
" + }) + $("#serch_user_list").html(s_html) + }) + } function submit_add_partner(){ - if($("input[name='user_id[]']:checked").length==0){ + if($("input[name='school[id]']:checked").length==0){ $("#checkNotice").html("请选择需要添加的内容").removeClass("none"); return; + }else{ + let checked_array = []; + $("input[name='school[id]']:checked").each(function () { + checked_array.push($(this).val()) + }); + let check_ids = {ids:checked_array}; + $.ajax({ + url: "/managements/add_partner", + type: 'POST', + data: check_ids, + success: function (e) { + if(e.status === 1){} + $("#popupAll").remove() + } + }) } } \ No newline at end of file diff --git a/app/views/managements/_profession_index.html.erb b/app/views/managements/_profession_index.html.erb index 668aa0f1..f8f906b3 100644 --- a/app/views/managements/_profession_index.html.erb +++ b/app/views/managements/_profession_index.html.erb @@ -37,13 +37,13 @@