This commit is contained in:
sw 2015-01-08 17:44:17 +08:00
commit 7ae9556404
11 changed files with 70 additions and 61 deletions

View File

@ -500,7 +500,8 @@ class CoursesController < ApplicationController
end end
end end
def course def
course
@school_id = params[:school_id] @school_id = params[:school_id]
per_page_option = 10 per_page_option = 10
if @school_id == "0" or @school_id.nil? if @school_id == "0" or @school_id.nil?

View File

@ -20,7 +20,7 @@ module CoursesHelper
# 返回教师数量即roles表中定义的Manager # 返回教师数量即roles表中定义的Manager
def teacherCount project def teacherCount project
searchTeacherAndAssistant(project).count project.members.count - studentCount(project).to_i
# or # or
# searchTeacherAndAssistant(project).count # searchTeacherAndAssistant(project).count
end end
@ -114,7 +114,7 @@ module CoursesHelper
# 学生人数计算 # 学生人数计算
# add by nwb # add by nwb
def studentCount course def studentCount course
searchStudent(course).count.to_s#course.student.count course.student.count.to_s#course.student.count
end end
#课程成员数计算 #课程成员数计算

View File

@ -38,7 +38,7 @@ class Course < ActiveRecord::Base
validates_presence_of :password, :term,:name validates_presence_of :password, :term,:name
validates_format_of :class_period, :with =>/^[1-9]\d*$/ validates_format_of :class_period, :with =>/^[1-9]\d*$/
validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000 validates_length_of :description, :maximum => 10000
before_save :self_validate before_save :self_validate
after_create :create_board_sync after_create :create_board_sync

View File

@ -1,8 +1,7 @@
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function () { function check_groupname() {
var $group_name = $('#group_name') var $group_name = $('#group_name');
$group_name.blur(function (event) {
if ($(this).is('#group_name')) {
$.get( $.get(
'<%=valid_ajax_course_path%>', '<%=valid_ajax_course_path%>',
{ valid: "name", { valid: "name",
@ -14,8 +13,7 @@
}); });
} }
});
});
</script> </script>
<script type=" text/javascript" charset="utf-8"> <script type=" text/javascript" charset="utf-8">
function validate_groupname(value1) { function validate_groupname(value1) {
@ -49,6 +47,7 @@
} }
function validate_add_group() { function validate_add_group() {
value1 = document.getElementById('group_name').value; value1 = document.getElementById('group_name').value;
check_groupname();
validate_groupname(value1); validate_groupname(value1);
validate_groupname_null(value1); validate_groupname_null(value1);

View File

@ -41,11 +41,14 @@
</td> </td>
<td rowspan="2" width="250px"> <td rowspan="2" width="250px">
<div class="project-search"> <div class="project-search">
<%= form_tag(:controller => 'bids', :action => 'contest', :method => :get) do %> <%= form_tag({:controller => 'bids', :action => 'contest'}, :id => "contest_search_form",:method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %> <%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'reward_type', @bid.reward_type %> <%= hidden_field_tag 'reward_type', @bid.reward_type %>
<%= hidden_field_tag 'project_type', params[:project_type] %> <%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <a href="#" onclick="$('#contest_search_form').submit();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%>
</a>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %> <% end %>
</div> </div>
</td> </td>

View File

@ -2,6 +2,8 @@
@nav_dispaly_forum_label = 1 @nav_dispaly_forum_label = 1
@nav_dispaly_course_label = nil @nav_dispaly_course_label = nil
@nav_dispaly_store_all_label = 1 %> @nav_dispaly_store_all_label = 1 %>
<% teacher_num = teacherCount(@course) %>
<% student_num = studentCount(@course) %>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@ -46,9 +48,13 @@
</td> </td>
<td rowspan="2" width="250px"> <td rowspan="2" width="250px">
<div class="top-content-search"> <div class="top-content-search">
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %> <%= form_tag({:controller => 'courses', :action => 'search'},:id => "course_search_form", :method => :get) do %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <%= text_field_tag 'name', params[:name], :size => 20, :style => "float:left" %>
<a href="#" onclick="$('#course_search_form').submit();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%>
</a>
<%#= submit_tag l(:label_search), :class => "ButtonColor m3p10", :name => nil, :style => "float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" %>
<% end %> <% end %>
</div> </div>
</td> </td>
@ -120,19 +126,19 @@
<td class="font_index"> <td class="font_index">
<!-- 1 教师; 2 学生0 全部--> <!-- 1 教师; 2 学生0 全部-->
<% if User.current.member_of_course?(@course) %> <% if User.current.member_of_course?(@course) %>
<%= link_to "#{teacherCount(@course)}", course_member_path(@course, :role => 1), :course => '1' %> <%= link_to "#{teacher_num}", course_member_path(@course, :role => 1), :course => '1' %>
<% else %> <% else %>
<span> <span>
<%= teacherCount(@course)%> <%= teacher_num %>
</span> </span>
<% end%> <% end%>
</td> </td>
<td class="font_index"> <td class="font_index">
<% if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) %> <% if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) %>
<%= link_to "#{studentCount(@course)}", course_member_path(@course, :role => 2), :course => '1' %> <%= link_to "#{student_num}", course_member_path(@course, :role => 2), :course => '1' %>
<% else %> <% else %>
<span> <span>
<%= studentCount(@course)%> <%= student_num %>
</span> </span>
<% end %> <% end %>
</td> </td>
@ -141,10 +147,10 @@
</td> </td>
<tr class="font_aram"> <tr class="font_aram">
<td align="center" width="80px" id="teacherCount"> <td align="center" width="80px" id="teacherCount">
<%= l(:label_x_base_courses_teacher, :count => teacherCount(@course)) %> <%= l(:label_x_base_courses_teacher, :count => teacher_num) %>
</td> </td>
<td align="center" width="80px" id="studentCount"> <td align="center" width="80px" id="studentCount">
<%= l(:label_x_base_courses_student, :count => studentCount(@course)) %> <%= l(:label_x_base_courses_student, :count => student_num) %>
</td> </td>
<td align="center" width="80px"> <td align="center" width="80px">
<%= l(:label_x_course_data, :count => files_count) %> <%= l(:label_x_course_data, :count => files_count) %>

View File

@ -61,12 +61,12 @@
if(regexName1()){$("#contst_search_form").submit();} if(regexName1()){$("#contst_search_form").submit();}
} }
</script> </script>
<div class="project-search"> <div class="project-search" style="float: left; margin: 0px">
<%= form_tag({controller: 'contests', action: 'index'}, method: :get, :id => "contst_search_form") do %> <%= form_tag({controller: 'contests', action: 'index'}, method: :get, :id => "contst_search_form") do %>
<%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => 'regexName1();', :width => "125px" %> <%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => 'regexName1();', :width => "125px", :style=>"float:left" %>
<%= hidden_field_tag 'project_type', params[:project_type] %> <%= hidden_field_tag 'project_type', params[:project_type] %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="padding-top: 7px !important;"> <a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%> <%= l(:label_search)%>
</a> </a>
<br /> <br />
@ -78,8 +78,8 @@
<tr> <tr>
<td> <td>
<%=link_to l(:field_homepage), home_path %> > <%=link_to l(:field_homepage), home_path %> >
<a> <a href="http://<%= Setting.host_contest %>" class="link_other_item">
<%=link_to l(:label_contest_innovate), home_path %> <%=l(:label_courses_management_platform)%>
</a> > </a> >
<span title="<%= @contest.name%>"> <span title="<%= @contest.name%>">
<%= link_to h(truncate(@contest.name, length: 20, omission: '...')), show_contest_contest_path(@contest) %> <%= link_to h(truncate(@contest.name, length: 20, omission: '...')), show_contest_contest_path(@contest) %>

View File

@ -64,10 +64,10 @@
} }
</script> </script>
<%= form_tag(projects_search_path, :method => :get, :id => "project_search_form") do %> <%= form_tag(projects_search_path, :method => :get, :id => "project_search_form") do %>
<%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => "regexName();" %> <%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => "regexName();", :style => "float:left" %>
<%= hidden_field_tag 'project_type', params[:project_type] %> <%= hidden_field_tag 'project_type', params[:project_type] %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" > <a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%> <%= l(:label_search)%>
</a> </a>
<br /> <br />

View File

@ -221,16 +221,16 @@
<div class="inf_user_context"> <div class="inf_user_context">
<table style="font-family:'微软雅黑'" width="240"> <table style="font-family:'微软雅黑'" width="240">
<tr> <tr>
<td style="padding-left: 5px" width="70px"> <td style=" float: right" width="70px">
<%= l(:label_user_joinin) %> <span style="float: right"> <%= l(:label_user_joinin) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<%= format_time(@user.created_on) %> <%= format_time(@user.created_on) %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="padding-left: 5px"> <td style=" float: right" width="70px">
<%= l(:label_user_login) %> <span style="float: right"> <%= l(:label_user_login) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px"> <td class="font_lighter_sidebar" style="padding-left: 0px">
<%= format_time(@user.last_login_on) %> <%= format_time(@user.last_login_on) %>
@ -239,8 +239,8 @@
<% unless @user.user_extensions.nil? %> <% unless @user.user_extensions.nil? %>
<% if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 %> <% if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 %>
<tr> <tr>
<td style="padding-left: 5px" width="70px"> <td style=" float: right" width="70px">
<%= l(:field_occupation) %> <span style="float: right"><%= l(:field_occupation) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<% unless @user.user_extensions.school.nil? %> <% unless @user.user_extensions.school.nil? %>
@ -250,8 +250,8 @@
</tr> </tr>
<% elsif @user.user_extensions.identity == 3 %> <% elsif @user.user_extensions.identity == 3 %>
<tr> <tr>
<td style="padding-left: 5px" width="70px"> <td style=" float: right" width="70px">
<%= l(:field_occupation) %> <span style="float: right"> <%= l(:field_occupation) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<%= @user.user_extensions.occupation %> <%= @user.user_extensions.occupation %>
@ -259,8 +259,8 @@
</tr> </tr>
<% elsif @user.user_extensions.identity == 2 %> <% elsif @user.user_extensions.identity == 2 %>
<tr> <tr>
<td style="padding-left: 18px" width="70px"> <td style=" float: right" width="70px">
<%= l(:label_company_name) %> <span style="float: right"> <%= l(:label_company_name) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<%= @user.firstname %> <%= @user.firstname %>
@ -268,8 +268,8 @@
</tr> </tr>
<% end %> <% end %>
<tr> <tr>
<td style="padding-left: 31px" width="76px"> <td style=" float: right" width="70px">
<%= l(:label_location) %> <span style="float: right"> <%= l(:label_location) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<%= @user.user_extensions.location %> <%= @user.user_extensions.location %>
@ -278,8 +278,8 @@
</tr> </tr>
<tr> <tr>
<% if @user.user_extensions.identity == 0 %> <% if @user.user_extensions.identity == 0 %>
<td style="padding-left: 31px" width="76px" > <td style=" float: right" width="70px" >
<%= l(:label_technical_title) %> <span style="float: right"> <%= l(:label_technical_title) %></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<span id = "td_tech_title"></span> <span id = "td_tech_title"></span>
@ -289,8 +289,8 @@
<% if @user.user_extensions.identity == 1 %> <% if @user.user_extensions.identity == 1 %>
<% if(is_watching?(@user) ) %> <% if(is_watching?(@user) ) %>
<tr> <tr>
<td style="padding-left: 31px" width="70px" > <td style=" float: right" width="70px" >
<%= l(:label_bidding_user_studentcode)%> <span style="float: right"> <%= l(:label_bidding_user_studentcode)%></span>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<%= @user.user_extensions.student_id %> <%= @user.user_extensions.student_id %>
@ -298,7 +298,7 @@
</tr> </tr>
<% else %> <% else %>
<tr> <tr>
<td style="padding-left: 31px" width="70px" > <td style=" float: right" width="70px" >
<%= l(:label_identity)%> <%= l(:label_identity)%>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
@ -309,7 +309,7 @@
<% end %> <% end %>
<% elsif @user.user_extensions.identity == 3 %> <% elsif @user.user_extensions.identity == 3 %>
<tr> <tr>
<td style="padding-left: 31px" width="70px" > <td style=" float: right" width="70px" >
<%= l(:label_identity)%> <%= l(:label_identity)%>
</td> </td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">

View File

@ -77,10 +77,10 @@
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%> <%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%> <%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<!--<%#= f.submit l(:button_project_tags_add),:class => "ButtonColor m3p10" %>--> <!--<%#= f.submit l(:button_project_tags_add),:class => "ButtonColor m3p10" %>-->
<a href="#" onclick='$("#tags_name").parent().submit();' class="ButtonColor m3p10" > <a href="#" onclick='$("#tags_name").parent().submit();' class="ButtonColor m3p10" style="padding: 3px 6px">
<%= l(:button_project_tags_add)%> <%= l(:button_project_tags_add)%>
</a> </a>
<%= link_to_function l(:button_cancel), '$("#put-tag-form").slideUp();',:class=>'ButtonColor m3p10'%> <%= link_to_function l(:button_cancel), '$("#put-tag-form").slideUp();',:class=>'ButtonColor m3p10' ,:style=>"padding:3px 6px"%>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

View File

@ -2912,7 +2912,7 @@ input[class~='ButtonClolr'],.ButtonColor{
input[class~='m3p10'], .m3p10 { input[class~='m3p10'], .m3p10 {
margin-top: 5px; margin-top: 5px;
padding: 5px 10px !important; padding: 5px 10px;
height: 20px; height: 20px;
display: inline-block; display: inline-block;
color: #ffffff; color: #ffffff;