dev_local
jasder 6 years ago
commit e154b3c7fe

@ -1177,6 +1177,48 @@ end
@partners = Partner.includes(:school) @partners = Partner.includes(:school)
end end
def all_partners
@search = params[:search]
@province = params[:province]
@schools = School.where("partner_id IS NULL").all
if params[:search]
@schools = @schools.where("name like ?", "%#{@search}%")
end
if params[:province]
@schools = @schools.where("province like ?", "%#{@province}%")
end
@page = (params['page'] || 1).to_i
@schools_count = @schools.count
@total_pages = (@schools_count / 10.0).ceil
@limit = 10
@is_remote = true
@schools_pages = Paginator.new @schools_count, @limit, @page
@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 def delete_depart_member
DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all

@ -9,6 +9,7 @@ class PollController < ApplicationController
before_filter :require_login, :only => [:student_poll_list, :show] before_filter :require_login, :only => [:student_poll_list, :show]
include PollHelper include PollHelper
include ApplicationHelper include ApplicationHelper
def index def index
if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?)
render_403 render_403
@ -18,13 +19,13 @@ class PollController < ApplicationController
if @is_teacher if @is_teacher
polls = @course.polls.order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") 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 member = @course.members.where(:user_id => User.current.id).first
if member.try(:course_group_id).to_i == 0 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") 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 = @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") 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 end
else else
@ -414,7 +415,6 @@ class PollController < ApplicationController
def update_poll_question def update_poll_question
@poll_question = PollQuestion.find params[:poll_question] @poll_question = PollQuestion.find params[:poll_question]
@poll = @poll_question.poll @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.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.max_choices = params[:max_choices].to_i || 0
@poll_question.min_choices = params[:min_choices].to_i || 0 @poll_question.min_choices = params[:min_choices].to_i || 0

@ -20,11 +20,11 @@
module PollHelper module PollHelper
def un_commit_num poll def un_commit_num poll
course = poll.course course = poll.course
member = course.members.where(:user_id => User.current.id).first member = course.members.where(:user_id => User.current.id).first ## 当前用户是否为课堂成员
poll_users = poll.poll_users poll_users = poll.poll_users # 问卷的全部用户,包含已回答的/为回答,但是浏览的
student_count = course.student.count student_count = course.student.count # 课堂的学生数
if member.present? && member.teacher_course_groups.count > 0 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 student_count = group_students.size
poll_users = poll_users.where(:user_id => group_students) poll_users = poll_users.where(:user_id => group_students)
end end

@ -1,5 +1,5 @@
class Customer < ActiveRecord::Base class Customer < ActiveRecord::Base
belongs_to :partner belongs_to :partner
has_one :scholl has_one :school
has_many :users has_many :users
end end

@ -1,7 +1,7 @@
<div class="task-popup" style="width: 572px;"> <div class="task-popup" style="width: 572px;">
<div class="task-popup-title clearfix">添加合作伙伴</div> <div class="task-popup-title clearfix">添加合作伙伴</div>
<div class="task_popup_con"> <div class="task_popup_con">
<div class="clearfix mb20 df"> <div class="clearfix mb5 df">
<div class="flex1"> <div class="flex1">
<div class="df"> <div class="df">
<span class="fl lineh-35">地区:</span> <span class="fl lineh-35">地区:</span>
@ -14,42 +14,26 @@
</div> </div>
<a href="javascript:void(0);" onclick="submit_search_user()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a> <a href="javascript:void(0);" onclick="submit_search_user()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a>
</div> </div>
<div class="mb20 clearfix"> <div class="mb4 clearfix">
<p class="pl10 color-grey-6 clearfix"> <p class="pl10 color-grey-6 clearfix">
<span class="fl ml25">单位</span> <span class="fl ml25">单位</span>
<span class="fr with30">地区</span> <span class="fr with30">地区</span>
</p> </p>
<div class="edu-back-skyblue clearfix pl10 over280" id="serch_user_list"> <div class="edu-back-skyblue clearfix pl10 over280" id="serch_user_list">
<p class="clearfix mt5">
<span class="fl with70">
<span>
<input type="checkbox" name="user_id[]" value="1" id="user_1" class="magic-checkbox">
<label for="user_1">国防科技大学</label>
</span>
</span>
<span class="fl with30">湖南</span>
</p>
<p class="clearfix mt5">
<span class="fl with70">
<span>
<input type="checkbox" name="user_id[]" value="12" id="user_12" class="magic-checkbox">
<label for="user_12">国防科技大学</label>
</span>
</span>
<span class="fl with30">湖南</span>
</p>
<p class="clearfix mt5">
<span class="fl with70">
<span>
<input type="checkbox" name="user_id[]" value="125" id="user_125" class="magic-checkbox">
<label for="user_125">国防科技大学</label>
</span>
</span>
<span class="fl with30">湖南</span>
</p>
</div> </div>
<p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p> <p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @schools_pages, @schools_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div> </div>
</div>
</div>
<li class="clearfix mt10 edu-txt-center"> <li class="clearfix mt10 edu-txt-center">
<a href="javascript:void(0);" class="task-btn mr10" onclick="hideModal()">取消</a> <a href="javascript:void(0);" class="task-btn mr10" onclick="hideModal()">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange ml20" onclick="submit_add_partner()">确定</a> <a href="javascript:void(0);" class="task-btn task-btn-orange ml20" onclick="submit_add_partner()">确定</a>
@ -60,12 +44,46 @@
$(function() { $(function() {
unitDownOption(); unitDownOption();
showprovince("province"); showprovince("province");
})
get_schools()
});
function get_schools() {
$.getJSON("/managements/all_partners",function(schools){
let s_html = "";
$.each(schools,function (index,array) {
s_html =s_html+ "<p class='clearfix mt5'>" +
" <span class='fl with70'>" +
" <span>" +
" <input type='checkbox' name='school[id]' value='"+array["school"]["id"]+"' id='school_'"+array["school"]["id"]+"'class='magic-checkbox'>" +
" <label for='school_'"+array["school"]["id"]+">"+array["school"]["name"]+"</label>" +
" </span>\n" +
" </span>\n" +
" <span class='fl with30'>"+array["school"]["province"]+"</span>" +
" </p>"
})
$("#serch_user_list").html(s_html)
})
}
function submit_add_partner(){ function submit_add_partner(){
if($("input[name='user_id[]']:checked").length==0){ if($("input[name='school[id]']:checked").length==0){
$("#checkNotice").html("请选择需要添加的内容").removeClass("none"); $("#checkNotice").html("请选择需要添加的内容").removeClass("none");
return; 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()
}
})
} }
} }
</script> </script>

@ -37,13 +37,13 @@
<td><%= format_time career.created_at %></td> <td><%= format_time career.created_at %></td>
<td><%= format_time career.published_at %></td> <td><%= format_time career.published_at %></td>
<td> <td>
<% if !career.status %> <%# if !career.status %>
<a href="javascript:void(0)" class="color-grey-6" onclick="post_confirm_box('<%= published_career_managements_path(:id => career.id) %>', '是否确定执行发布操作?')">发布</a> <!-- <a href="javascript:void(0)" class="color-grey-6" onclick="post_confirm_box('<%= published_career_managements_path(:id => career.id) %>', '是否确定执行发布操作?')">发布</a>-->
<% end %> <%# end %>
<a href="<%= edit_introduction_career_path(career) %>" class="color-grey-6" target="_blank">编辑</a> <!-- <a href="<%#= edit_introduction_career_path(career) %>" class="color-grey-6" target="_blank">编辑</a>-->
<% if !career.status %> <%# if !career.status %>
<a href="javascript:void(0)" class="color-grey-6" onclick="delete_confirm_box_2('<%= delete_career_managements_path(:id => career.id) %>', '是否确定执行删除操作?')">删除</a> <!-- <a href="javascript:void(0)" class="color-grey-6" onclick="delete_confirm_box_2('<%= delete_career_managements_path(:id => career.id) %>', '是否确定执行删除操作?')">删除</a>-->
<% end %> <%# end %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

@ -9,7 +9,7 @@
<a href="javascript:void(0)" class="color-blue addOperation">+添加</a> <a href="javascript:void(0)" class="color-blue addOperation">+添加</a>
<ul class="partnerList"> <ul class="partnerList">
<% @partners.each_with_index do |partner,index| %> <% @partners.each_with_index do |partner,index| %>
<li><a class="active" href=""><%= partner.school.name %></a></li> <li><a class="active" href=""><%= partner.name %></a></li>
<% end %> <% end %>
</ul> </ul>
</div> </div>
@ -66,6 +66,7 @@
}) })
$(".manageList").on("click",".addManage",function(){ $(".manageList").on("click",".addManage",function(){
var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>";
pop_box_new(html,572,500); pop_box_new(html,572,500);
}) })

@ -555,6 +555,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'departments', :via => [:get, :post] match 'departments', :via => [:get, :post]
get 'partners' get 'partners'
get 'add_partner_member_box' get 'add_partner_member_box'
get 'all_partners'
post 'add_partner'
delete 'delete_depart_member' delete 'delete_depart_member'
get 'add_depart_member_box' get 'add_depart_member_box'
post 'add_depart_member' post 'add_depart_member'

@ -4,4 +4,4 @@ You are allowed to:
1. Remove rake task 1. Remove rake task
2. Add existing rake tasks 2. Add existing rake tasks
To add existing rake tasks automatically delete this file and reload the project. To add existing rake tasks automatically delete this file and reload the project.
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Run the given task for all appraisals" fullCmd="appraisal" taksId="appraisal" /><RakeGroup description="" fullCmd="" taksId="appraisal"><RakeTask description="DEPRECATED: Remove all generated gemfiles from gemfiles/ folder" fullCmd="appraisal:cleanup" taksId="cleanup" /><RakeTask description="DEPRECATED: Generate a Gemfile for each appraisal" fullCmd="appraisal:gemfiles" taksId="gemfiles" /><RakeTask description="DEPRECATED: Resolve and install dependencies for each appraisal" fullCmd="appraisal:install" taksId="install" /><RakeTask description="" fullCmd="appraisal:all" taksId="all" /></RakeGroup><RakeTask description="Run tests for bench" fullCmd="bench" taksId="bench" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Remove RDoc HTML files" fullCmd="clobber_rdoc" taksId="clobber_rdoc" /><RakeTask description="Build RDoc HTML files" fullCmd="rdoc" taksId="rdoc" /><RakeTask description="Rebuild RDoc HTML files" fullCmd="rerdoc" taksId="rerdoc" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="html" taksId="html" /><RakeTask description="" fullCmd="html/index.html" taksId="html/index.html" /><RakeTask description="" fullCmd="file" taksId="file" /><RakeTask description="" fullCmd="test_all" taksId="test_all" /></RakeGroup></Settings> --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>

@ -4,4 +4,4 @@ You are allowed to:
1. Remove rake task 1. Remove rake task
2. Add existing rake tasks 2. Add existing rake tasks
To add existing rake tasks automatically delete this file and reload the project. To add existing rake tasks automatically delete this file and reload the project.
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gitlab-3.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install gitlab-3.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v3.2.0 and build and push gitlab-3.2.0.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings> --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gitlab-3.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install gitlab-3.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install gitlab-3.2.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v3.2.0 and build and push gitlab-3.2.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>

Loading…
Cancel
Save