diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 4c558379..1be642d7 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -206,7 +206,7 @@ class CompetitionTeamsController < ApplicationController teacher_staff = @competition.competition_staffs.where(category: 'teacher').first if teacher_staff.blank? - @status, @message = -1, '老师不能参加该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:学生' return end @@ -218,7 +218,7 @@ class CompetitionTeamsController < ApplicationController else max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) if max_member_count.zero? - @status, @message = -1, '学生不能参加该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:教师' return elsif team.members.count + 1 > max_member_count @status, @message = -1, '该战队成员人数已满' @@ -277,16 +277,18 @@ class CompetitionTeamsController < ApplicationController end def member_and_teacher_count_valid?(is_teacher) + single_staff = @competition.competition_staffs.count == 1 + teacher_text = single_staff ? '队员' : '导师' teacher_staff = @competition.competition_staffs.where(category: 'teacher').first teacher_count = params[:teacher_ids].try(:size) || 0 teacher_count += 1 if is_teacher # 检查老师数量 if teacher_staff.blank? && teacher_count > 0 - @status, @message = -1, '老师不能参与该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:学生' return false elsif teacher_staff.present? && (teacher_staff.minimum > teacher_count || teacher_staff.maximum < teacher_count) @status = -1 - @message = teacher_staff.maximum == teacher_staff.maximum ? "导师数量应为#{teacher_staff.minimum}人" : "导师数量应为#{teacher_staff.minimum}-#{teacher_staff.maximum}人" + @message = teacher_staff.maximum == teacher_staff.maximum ? "#{teacher_text}数量应为#{teacher_staff.minimum}人" : "#{teacher_text}数量应为#{teacher_staff.minimum}-#{teacher_staff.maximum}人" return false end @@ -297,11 +299,11 @@ class CompetitionTeamsController < ApplicationController member_count += 1 unless is_teacher # 检查成员数据 if member_relations.count.zero? && member_count > 0 - @status, @message = -1, '学生不能参与该竞赛' + @status, @message = -1, '本竞赛的参赛者限定为:教师' return false elsif min_member_count > member_count || member_count > max_member_count @status = -1 - @message = min_member_count == max_member_count ? "成员数量应为#{max_member_count}人" : "成员数量应为#{min_member_count}-#{max_member_count}人" + @message = min_member_count == max_member_count ? "队员数量应为#{max_member_count}人" : "队员数量应为#{min_member_count}-#{max_member_count}人" return false end @@ -327,7 +329,7 @@ class CompetitionTeamsController < ApplicationController repeat_members = competition.team_members.where(user_id: user_ids).includes(:user).to_a if repeat_members.size > 0 - @status, @message = -1, "成员#{repeat_members.map{|t| t.user.show_real_name}.join(',')}已经加入其它战队了" + @status, @message = -1, "队员#{repeat_members.map{|t| t.user.show_real_name}.join(',')}已经加入其它战队了" return false end diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index a868cbf0..e73c779a 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -25,7 +25,15 @@ class CompetitionsController < ApplicationController end def index - @competitions = Competition.where('status = 1 or published_at is not null').reorder("published_at desc, online_time desc") + competitions = Competition.where('status = 1 or published_at is not null') + + case params[:category] + when 'progressing' then + competitions = competitions.where('end_time > NOW()') + when 'ended' then + competitions = competitions.where('end_time < NOW()') + end + @competitions = competitions.reorder("published_at desc, online_time desc") respond_to do |format| format.html { render :layout => "base_edu"} format.js @@ -479,7 +487,7 @@ class CompetitionsController < ApplicationController if params[:competition_module] @competition.competition_modules.where(:id => params[:competition_module], :md_edit => false).update_all(:hidden => 0) - none_modules = @competition.competition_modules.where("name != '首页' and md_edit = false").map(&:id).join(",").split(",") - params[:competition_module] + none_modules = @competition.competition_modules.where("name != '首页' and md_edit = false").pluck(:id) - params[:competition_module].map(&:to_i) @competition.competition_modules.where(:id => none_modules).update_all(:hidden => 1) end if params[:name] diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index ecbe41e4..16efc0c5 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -37,7 +37,7 @@ class LibrariesController < ApplicationController Libraries::SaveService.new(@library, current_user, form_params).call if with_publish? Libraries::SubmitService.new(@library).call - redirect_to publish_success_libraries_path + redirect_to publish_success_libraries_path(id: @library.id) else redirect_to library_path(id: @library.id) end @@ -61,7 +61,7 @@ class LibrariesController < ApplicationController Libraries::SaveService.new(@library, current_user, form_params).call if with_publish? Libraries::SubmitService.new(@library).call - redirect_to publish_success_libraries_path + redirect_to publish_success_libraries_path(id: @library.id) else redirect_to library_path(id: @library.id) end diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index d3336e08..dc8f6dea 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1083,7 +1083,12 @@ end def enroll_list @order = params[:order].blank? ? "desc" : params[:order] @competition = Competition.where(:id => params[:competition]).first - @team_members = @competition.team_members.includes(:user => [:user_extensions => [:school]]) + + @only_teacher = @competition.competition_staffs.count == 1 && @competition.competition_staffs.first.category == 'teacher' + + @team_members = @competition.team_members + @team_members = @team_members.where(is_teacher: false) unless @only_teacher # 只有老师报名时才显示老师,此时老师作为队员 + if params[:school] || params[:location] school_ids = School.where("schools.name like '%#{params[:school]}%'").pluck(:id) school_ids = school_ids.size == 0 ? "(-1)" : "(" + school_ids.join(",") + ")" @@ -1093,7 +1098,7 @@ end @page = params[:page] || 1 @team_members = @team_members.reorder("team_members.created_at #{@order}") all_members = @team_members - @team_members = paginateHelper @team_members, 50 + @team_members = paginateHelper(@team_members.includes(competition_team: [:user, teachers: :user], user: { user_extensions: :school }), 50) respond_to do |format| format.js format.html diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 345dfadc..39298061 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2996,6 +2996,8 @@ module ApplicationHelper else title << "教学案例" end + elsif params[:controller] == "project_packages" + title << "众包社区" elsif @course title << (@course.name.nil? ? "课堂" : @course.name) elsif params[:controller] == "homework_bank" || params[:controller] == "question_banks" || params[:controller] == "exercise_bank" @@ -7468,7 +7470,7 @@ def tiding_url tiding tiding.tiding_type == 'Apply' ? library_applies_path : library_path(tiding.container_id) when 'ProjectPackage' if tiding.container.present? - tiding.tiding_type == 'Apply' ? project_package_applies_path : "/project_packages/#{tiding.container_id}" + tiding.tiding_type == 'Apply' ? project_package_applies_path : "/crowdsourcing/#{tiding.container_id}" else 'javascript:void(0)' end diff --git a/app/helpers/libraries_helper.rb b/app/helpers/libraries_helper.rb index 4d6956b7..e2e74324 100644 --- a/app/helpers/libraries_helper.rb +++ b/app/helpers/libraries_helper.rb @@ -2,7 +2,7 @@ module LibrariesHelper def show_library_tags(library) html = '' library.library_tags.each do |tag| - html += content_tag(:span, tag.name, class: "edu-filter-btn fl cdefault mt3 ml10 " + library_tag_class(tag)) + html += content_tag(:span, tag.name, class: "edu-filter-btn fl cdefault mt3 ml10 #{library_tag_class(tag)}") end raw html diff --git a/app/views/competition_teams/_competition_team_form.html.erb b/app/views/competition_teams/_competition_team_form.html.erb index c68cc3b2..3f076d6a 100644 --- a/app/views/competition_teams/_competition_team_form.html.erb +++ b/app/views/competition_teams/_competition_team_form.html.erb @@ -1,4 +1,5 @@ <% none_edit = @team.try(:id).present? && @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> +<% single_staff = @competition.competition_staffs.count == 1 %> <%= labelled_form_for @team, :html => {:id => 'competition_team_form', :multipart => true, :remote => true} do |f| %> <% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %> <% min_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:minimum) %> @@ -10,19 +11,19 @@ - <% if none_edit %> + <% if teacher_staff && none_edit %>

报名已截止,只能编辑导师信息

<% end %>
- maxlength="20" value="<%= @team.try(:name) %>" class="input-flex-35" placeholder="请输入您的组队名称"/> + maxlength="20" value="<%= @team.try(:name) %>" class="input-flex-35" placeholder="请输入您的战队名称"/>

<% if teacher_staff.present? %>
- +
"> @@ -41,7 +42,7 @@
- autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input"> + autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的队员搜索" id="user_search_input"> @@ -51,7 +52,7 @@
- +

<% end %> @@ -68,7 +69,7 @@ <% creator_teacher = @team.user.user_extensions.identity == 0 %>

<%= @team.user.show_name %> - <%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %> + <%= @team.user.user_extensions.identity == 0 ? "#{ single_staff ? '队长' : '导师' }/创建者" : "#{ single_staff ? '队长/' : '' }创建者" %> <%= @team.user.school_name %> <%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %> @@ -79,7 +80,7 @@

<%= teacher.user.show_name %> - 导师 + <%= single_staff ? '队员' : '导师' %> <%= teacher.user.school_name %> 职称:<%= teacher.user.identity %> @@ -91,7 +92,7 @@

<%= team_user.user.show_name %> - 成员 + 队员 <%= team_user.user.school_name %> 学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %> @@ -105,7 +106,7 @@ <% creator_teacher = @team_user.user_extensions.identity == 0 %>

<%= @team_user.show_name %> - <%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %> + <%= @team_user.user_extensions.identity == 0 ? "#{ single_staff ? '队长' : '导师' }/创建者" : "#{ single_staff ? '队长/' : '' }创建者" %> <%= @team_user.school_name %> <%= @team_user.user_extensions.identity == 0 ? "职称:#{@team_user.identity}" : "学号:#{@team_user.user_extensions.student_id.present? ? @team_user.user_extensions.student_id : "--"}" %> @@ -167,7 +168,7 @@ var li = '

' + ' ' + ' '+$("#teacher_name").val()+'' + - ' 导师' + + ' <%= single_staff ? "队员" : "导师" %>' + ' '+$("#teacher_school").val()+'' + ' 职称:'+$("#teacher_title").val()+'' + ' ' + @@ -193,7 +194,7 @@ var li = '

' + ' ' + ' '+$("#member_name").val()+'' + - ' 成员' + + ' 队员' + ' '+$("#member_school").val()+'' + ' 学号:'+$("#member_student_id").val()+'' + ' ' + diff --git a/app/views/competition_teams/_search_teacher_list.html.erb b/app/views/competition_teams/_search_teacher_list.html.erb index 9847daec..ab7adcd8 100644 --- a/app/views/competition_teams/_search_teacher_list.html.erb +++ b/app/views/competition_teams/_search_teacher_list.html.erb @@ -1,4 +1,4 @@ -

请选择指导老师,允许修改

+ <% @teachers.each do |teacher| %> <% has_enroll = @competition.teacher_enroll_mutiple_limited && (@team.present? ? @competition.team_members.where("user_id = '#{teacher.id}' and id != #{@team.id}").count > 0 : @competition.team_members.where("user_id = '#{teacher.id}'").count > 0) %> diff --git a/app/views/competitions/_add_md_contents.html.erb b/app/views/competitions/_add_md_contents.html.erb index e8dedec6..eca7adf8 100644 --- a/app/views/competitions/_add_md_contents.html.erb +++ b/app/views/competitions/_add_md_contents.html.erb @@ -42,7 +42,7 @@
<% end %> diff --git a/app/views/competitions/_ccf_competition.html.erb b/app/views/competitions/_ccf_competition.html.erb index 8d59e0c4..36429708 100644 --- a/app/views/competitions/_ccf_competition.html.erb +++ b/app/views/competitions/_ccf_competition.html.erb @@ -5,8 +5,10 @@

- 入库标准 - 使用说明 + <% com_module_1 = @competition.competition_modules.where(:hidden => 0, :name => '入库标准').first %> + 入库标准 + <% com_module_2 = @competition.competition_modules.where(:hidden => 0, :name => '使用说明').first %> + 使用说明

diff --git a/app/views/competitions/_competition_list.html.erb b/app/views/competitions/_competition_list.html.erb new file mode 100644 index 00000000..13e8d3c8 --- /dev/null +++ b/app/views/competitions/_competition_list.html.erb @@ -0,0 +1,100 @@ +<% if @competitions.count > 0 %> +
+ <% @competitions.each do |competition| %> + <% if competition.status? %> +
+
+ <% if competition.enroll_end_time.present? && competition.enroll_end_time > Time.now %> +
报名中
+ <% end %> + + <%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %> + +
+ <%= [competition.name, competition.sub_title.presence].compact.join('——') %> + <% if competition.start_time > Time.now %> + <% unless competition.enroll_end_time.present? && competition.enroll_end_time < Time.now %> +
+ + 报名中 +
+ <% else %> +
+ + 即将开始 +
+ <% end %> + <% elsif competition.end_time < Time.now %> +
+ + 已结束 +
+ <% else %> + <% max_min_stage = max_min_stage_time competition %> + <% if max_min_stage.count == 1 %> +
+ + 距离结束还剩<%= how_much_day competition.end_time %> +
+ <% else %> + <% max_min_stage.each do |stage| %> + <% if stage.min_start_time > Time.now %> +
+ + <%= stage.competition_stage.name %>即将开始 +
+ <% break %> + <% elsif stage.max_end_time > Time.now %> +
+ + <%= stage.competition_stage.name %>正在进行 +
+ <% break %> + <% end %> + <% end %> + <% end %> + <% end %> +
+

+ <%= format_date competition.start_time %> ~ <%= com_end_date competition.end_time %> + + <%= competition.visits %> + <% if competition.member_count > 0 %> + + + <%= competition.identifier == "hn" ? 1125 : competition.member_count %> + + + <% end %> + +

+
+
+ <% elsif competition.published_at.present? %> + <% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %> +
+ +
+
+

即将发布

敬请期待

+
+
+
+ <% end %> + <% end %> +
+<% else %> + <%= render :partial => "welcome/no_data" %> +<% end %> \ No newline at end of file diff --git a/app/views/competitions/_header.html.erb b/app/views/competitions/_header.html.erb index f4e0e912..18e284ec 100644 --- a/app/views/competitions/_header.html.erb +++ b/app/views/competitions/_header.html.erb @@ -55,7 +55,7 @@ <%= com_module.name %> <% else %> -
  • "> +
  • "> com_module.competition_module_md_content.try(:id))}" %>" target="_blank"><%= com_module.name %>
  • <% end %> diff --git a/app/views/competitions/index.html.erb b/app/views/competitions/index.html.erb index c8743251..36743613 100644 --- a/app/views/competitions/index.html.erb +++ b/app/views/competitions/index.html.erb @@ -1,101 +1,19 @@
    - <% if @competitions.count > 0 %> -
    - <% @competitions.each do |competition| %> - <% if competition.status? %> -
    -
    - - <%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %> - -
    - <%= [competition.name, competition.sub_title.presence].compact.join('——') %> - <% if competition.start_time > Time.now %> - <% unless competition.enroll_end_time.present? && competition.enroll_end_time < Time.now %> -
    - - 报名中 -
    - <% else %> -
    - - 即将开始 -
    - <% end %> - <% elsif competition.end_time < Time.now %> -
    - - 已结束 -
    - <% else %> - <% max_min_stage = max_min_stage_time competition %> - <% if max_min_stage.count == 1 %> -
    - - 距离结束还剩<%= how_much_day competition.end_time %> -
    - <% else %> - <% max_min_stage.each do |stage| %> - <% if stage.min_start_time > Time.now %> -
    - - <%= stage.competition_stage.name %>即将开始 -
    - <% break %> - <% elsif stage.max_end_time > Time.now %> -
    - - <%= stage.competition_stage.name %>正在进行 -
    - <% break %> - <% end %> - <% end %> - <% end %> - <% end %> -
    -

    - <%= format_date competition.start_time %> ~ <%= com_end_date competition.end_time %> - - <%= competition.visits %> - <% if competition.member_count > 0 %> - - - <%= competition.identifier == "hn" ? 1125 : competition.member_count %> - - - <% end %> - -

    -
    -
    - <% elsif competition.published_at.present? %> - <% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %> - - <% end %> - <% end %> -
    - <% else %> - <%= render :partial => "welcome/no_data" %> - <% end %> + +
    + <%= link_to '全部', competitions_path(category: ''), remote: true, + class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category].blank? ? 'active' : ''}" %> + <%= link_to '进行中', competitions_path(category: 'progressing'), remote: true, + class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'progressing' ? 'active' : ''}" %> + <%= link_to '往期比赛', competitions_path(category: 'ended'), remote: true, + class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'ended' ? 'active' : ''}" %> +
    + +
    + <%= render 'competitions/competition_list' %> +
    + +