实训添加合作者功能
This commit is contained in:
parent
aa7bb35cc9
commit
f88bf9bcdb
|
|
@ -36,12 +36,41 @@ class ShixunsController < ApplicationController
|
|||
end
|
||||
|
||||
def propaedeutics
|
||||
@shixun = Shixun.find_by_identifier(params[:id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def collaborators
|
||||
@collaborators = @shixun.collaborators
|
||||
end
|
||||
|
||||
# 已存在的成员不添加
|
||||
def add_collaborators
|
||||
if !params[:search].nil?
|
||||
# members = searchTeacherAndAssistant @course
|
||||
member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")"
|
||||
condition = "%#{params[:search].strip}%".gsub(" ","")
|
||||
@users = User.where("id not in #{member_ids} and status = 1 and LOWER(concat(lastname, firstname)) LIKE '#{condition}'").includes(:user_extensions)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def shixun_members_added
|
||||
unless params[:membership][:user_ids].blank?
|
||||
memberships = params[:membership][:user_ids]
|
||||
memberships.each do |member|
|
||||
ShixunMember.create(:user_id => member, :shixun_id => @shixun.id, :role => 2)
|
||||
end
|
||||
@collaborators = @shixun.collaborators
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def search
|
||||
# 确定 sort 1升序 2 降序
|
||||
if params[:time_reorder]
|
||||
|
|
|
|||
|
|
@ -18,4 +18,8 @@ class Shixun < ActiveRecord::Base
|
|||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def collaborators
|
||||
self.shixun_members.select{|member| member.role == 2} unless self.shixun_members.blank?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
|
|
@ -538,6 +539,18 @@ class User < Principal
|
|||
self.read_attribute(:identity_url)
|
||||
end
|
||||
|
||||
# 判断用户的身份
|
||||
def identity
|
||||
ue = self.user_extensions
|
||||
unless ue.blank?
|
||||
if ue.technical_title.blank?
|
||||
ue.identity == 0 ? "老师" : (ue.identity == 1 ? "学生" : "专业人士")
|
||||
else
|
||||
result = ue.technical_title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
|
||||
VALID_PHONE_REGEX = /^1\d{10}$/
|
||||
# VALID_EMAIL_REGEX = /^[0-9a-zA-Z_-]+@[0-9a-zA-Z_-]+(\.[0-9a-zA-Z_-]+)+$/
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
<% end %>
|
||||
<li><a href="<%= statistics_shixun_path(@shixun) %>" class="<%= params[:action] == "statistics" ? "active" : "" %>">统计</a></li>
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<li><a href="<%= collaborators_shixun_path(@shixun) %>" class="<%= params[:action] == "collaborators" ? "active" : "" %>">合作者</a></li>
|
||||
<li><a href="<%= settings_shixun_path(@shixun) %>" class="<%= params[:action] == "settings" ? "active" : "" %>">配置</a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
@ -65,6 +66,6 @@
|
|||
</body>
|
||||
<!-- MathJax的配置 -->
|
||||
<script type="text/javascript" src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<%= javascript_include_tag 'application', 'cookie','project',"avatars", 'header','prettify','select_list_move','attachments' %>
|
||||
<%= javascript_include_tag 'application', 'cookie','project',"avatars", 'header','prettify','select_list_move','attachments','edu/shixun','edu/application' %>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<!-------------------添加教师\助教--------------------------->
|
||||
<div class="task-popup newteacher" style="width:600px;">
|
||||
<div class="task-popup-title clearfix task-popup-bggrey">
|
||||
<h3 class="fl ">添加合作者</h3>
|
||||
<a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>
|
||||
</div>
|
||||
<div class="task_popup_con">
|
||||
<div class="newupload_conbox clearfix">
|
||||
<%= form_tag url_for(shixun_members_added_shixun_path(@shixun)), :remote => true, :method => :post, :id => 'add_collaborators_form' do |f| %>
|
||||
<div class="left fl" style="width:530px;">
|
||||
<div class="mb10 edu-position" style="width:530px;">
|
||||
<input type="hidden" value="<%= @shixun.identifier %>" id="shixun_collaborators_id">
|
||||
<input class="task-form-100 task-height-40 panel-box-sizing" id="search_not_collaborators" placeholder="输入用户的真实姓名进行搜索" type="text">
|
||||
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey mt5"><i class="fa fa-search"></i></a>
|
||||
</div>
|
||||
<div class="clearfix mb15">
|
||||
<ul class="upload_select_box fl" style="overflow-y:auto;width:510px;" id="search_not_teachers_list">
|
||||
<%#= render :partial => 'courses/settings/search_not_teachers_list' %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="pop_close task-btn mb10" style="margin-top: 20px;">取消</a>
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-blue" style="margin-top: 20px;" onclick="submit_add_collaborators_form()">确定</a>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<span class="color-orange fl none" id="add_teacher_notice"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<% @collaborators.each do |collaborators| %>
|
||||
<div class="fl task-width33 panel-box-sizing mb20">
|
||||
<a class="fl"><%= image_tag(url_to_avatar(collaborators.user), :width => 60, :height => 60,:class => 'panel-list-img mr15 mt5') %></a>
|
||||
<ul class="fl font-12 color-grey">
|
||||
<li><a href="<%= user_path(collaborators.user) %>" class="font-16 mt5 link-name-dark task-hide"><%= collaborators.user.try(:show_name) %></a></li>
|
||||
<li><span class="mr30"><%= collaborators.user.identity %></span> <a href="#" class="link-color-grey">删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<% if params[:is_observe] %>
|
||||
$("#search_not_teachers_list").html("<%= j(render :partial => 'courses/settings/search_not_teachers_list') %>");
|
||||
<% else %>
|
||||
var htmlvalue = "<%= j(render :partial => 'shixuns/add_collaborators') %>";
|
||||
pop_box_new(htmlvalue, 600, 420);
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<div class="task-pm-content edu-con-bg01 " style="margin-top:20px;">
|
||||
<div class="clearfix task-partner-list">
|
||||
<a class="fl"><%= image_tag(url_to_avatar(@shixun.owner), :width => 60, :height => 60, :class => 'panel-list-img mr15 mt5') %></a>
|
||||
<ul class="fl font-12 color-grey">
|
||||
<li><a href="<%= user_path(@shixun.owner) %>" class="font-16 mt5 link-name-dark task-hide"><%= @shixun.owner.try(:show_name) %></a></li>
|
||||
<li><span class="mr30"><%= @shixun.owner.identity %></span><span>管理员</span></li>
|
||||
</ul>
|
||||
<a href="<%= add_collaborators_shixun_path(@shixun) %>" class="task-btn task-btn-green fr mt20" data-remote="true"><i class="fa fa-plus mr5" ></i>合作者</a>
|
||||
</div>
|
||||
<div class="clearfix padding15" id="collaborators_list">
|
||||
<%= render :partial => "shixuns/collaborators_list" %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1 @@
|
|||
$("#collaborators_list").html("<%= j(render :partial => 'shixuns/collaborators_list') %>");
|
||||
|
|
@ -36,9 +36,13 @@ RedmineApp::Application.routes.draw do
|
|||
member do
|
||||
get 'statistics'
|
||||
get 'propaedeutics'
|
||||
get 'collaborators'
|
||||
match 'add_collaborators', :via => [:get, :post]
|
||||
post 'shixun_members_added'
|
||||
get 'shixun_monitor'
|
||||
get 'shixun_exec'
|
||||
post 'add_script'
|
||||
post 'shixun_members'
|
||||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||
get 'shixun_job_create'
|
||||
get 'shixun_job_update'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
$(function() {
|
||||
$("#search_not_collaborators").live('input', function (e) {
|
||||
throttle(search_not_teacher_f, window, e);
|
||||
});
|
||||
});
|
||||
|
||||
var lastteSearchCondition = '';
|
||||
function search_not_teacher_f(e){
|
||||
if($(e.target).val().trim() == "" || ($(e.target).val().trim() == lastteSearchCondition && lastteSearchCondition != ''))
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastteSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '/shixuns/' + $("#shixun_collaborators_id").val() + '/add_collaborators',
|
||||
type:'post',
|
||||
data: {is_observe:true, search:e.target.value},
|
||||
success: function(data){ }
|
||||
});
|
||||
}
|
||||
|
||||
function submit_add_collaborators_form(){
|
||||
if($("input[name='membership[user_ids][]']:checked").length >= 1){
|
||||
$("#add_teacher_notice").html("").hide();
|
||||
$("#add_collaborators_form").submit();
|
||||
hideModal();
|
||||
}else{
|
||||
$("#add_teacher_notice").html("请至少选择一个用户").show();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue