Conflicts:
	app/views/competitions/enroll.html.erb
dev_bj
caishi 5 years ago
commit a88becc482

@ -12,6 +12,34 @@ class CompetitionTeamsController < ApplicationController
@team_user = User.current
end
def show
return render_404 if @competition.identifier != 'gcc-course-2019'
@team_user_ids = @team.team_members.pluck(:user_id)
shixuns = Shixun.where(user_id: @team_user_ids, status: 2)
shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2')
shixuns = shixuns.joins('left join myshixuns on myshixuns.shixun_id = shixuns.id and exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count')
@shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator)
@myshixun_count_map = Myshixun.where(shixun_id: @shixuns.map(&:id))
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
.group('shixun_id').count
# todo使用新版course_members
course_ids = Course.joins('join members on members.course_id = courses.id')
.joins('join member_roles on member_roles.member_id = members.id and member_roles.role_id in (3,7,9)')
.where(members: { user_id: @team_user_ids }).pluck(:id)
courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()')
@courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count')
.group('courses.id').order('shixun_homework_count desc')
@course_myshixun_map = Myshixun.joins(student_works: :homework_common)
.where(homework_commons: { course_id: @courses.map(&:id) })
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
.group('homework_commons.course_id').count
end
def search_teacher
if params[:team] && params[:team] != ""
@team = @competition.competition_teams.where(:id => params[:team]).first

@ -4,7 +4,7 @@ class CompetitionsController < ApplicationController
:edit_md_content, :update_md_content,
:new_competition_stage, :new_stage_section, :update_competition_stage]
before_filter :find_inform, :only => [:edit_inform, :update_inform]
before_filter :require_login, :only => [:enroll_portal]
before_filter :require_login, :only => [:enroll_portal, :publish]
skip_before_filter :verify_authenticity_token, :only => [:edit_rule]
layout 'base_competition'
@ -25,7 +25,7 @@ class CompetitionsController < ApplicationController
end
def index
@competitions = Competition.where(:status => 1).reorder("online_time desc")
@competitions = Competition.where('status = 1 or published_at is not null').reorder("published_at desc, online_time desc")
respond_to do |format|
format.html { render :layout => "base_edu"}
format.js
@ -438,10 +438,10 @@ class CompetitionsController < ApplicationController
def online_switch
if @competition.present?
if @competition.status
@competition.update_attributes(:status => 0)
@competition.update_attributes(status: false, published_at: nil)
@btn_html = "上架"
else
@competition.update_attributes(:status => 1, :online_time => Time.now)
@competition.update_attributes(status: true, online_time: Time.now, published_at: nil)
@btn_html = "下架"
end
end
@ -601,6 +601,12 @@ class CompetitionsController < ApplicationController
@competition.competition_stage_sections.where(:id => params[:section_id]).destroy_all
end
def publish
return render_403 unless admin_or_business?
@competition.update_column(:published_at, Time.now)
end
private
def chart_exp_score_mo myshixuns, s_time, e_time

@ -24,13 +24,12 @@
<div class="df pl20 pr20">
<label class="ml10 mt3">导师:</label>
<div class="flex1 pr search-new">
<input type="text" class="input-100-35 fl" <%= @team_user.user_extensions.identity == 0 ? "disabled" : "" %> autocomplete="off" placeholder="请您输入老师姓名进行搜索;可以后续再添加导师" id="teacher_search_input"
value="<%= @team.try(:id).present? ? @team.teacher.try(:show_name) : (@team_user.user_extensions.identity == 0 ? @team_user.show_name : "") %>">
<input type="text" class="input-100-35 fl" autocomplete="off" placeholder="请您输入老师姓名进行搜索;可以后续再添加导师" id="teacher_search_input" value="">
<input type="hidden" id="teacher_id" data-select="0" value="<%= @team.try(:id).present? ? @team.try(:teacher_id) : (@team_user.user_extensions.identity == 0 ? @team_user.id : "") %>">
<input type="hidden" id="teacher_name" value="<%= @team.try(:id).present? ? @team.teacher.try(:show_name) : (@team_user.user_extensions.identity == 0 ? @team_user.show_name : "") %>">
<input type="hidden" id="teacher_school">
<input type="hidden" id="teacher_title">
<a class="fl searchicon" style="top:0px;" onclick="<%= @team_user.user_extensions.identity == 0 ? '' : 'search_teacher_user()' %>"><i class="iconfont icon-sousuo fl"></i></a>
<a class="fl searchicon" style="top:0px;" onclick="search_teacher_user()"><i class="iconfont icon-sousuo fl"></i></a>
<ul class="pointerTeacher none" id="pointerTeacher">
</ul>
</div>

@ -0,0 +1,120 @@
<div class="educontent mb50">
<p class="edu-back-white mb20 padding30 mt10 clearfix lineh-20">
<span class="color-grey-3 font-18 fl">战队详情</span>
<%= link_to '返回', enroll_competition_path(@competition), class: 'color-grey-9 fr' %>
</p>
<div class="edu-back-white mb20">
<p class="pt20 pb20 font-16"><span class="modalTitle">实训项目</span></p>
<table width="100%" class="tBodyScroll edu-txt-center" cellpadding="0" cellspacing="0">
<thead class="lastPart">
<tr>
<th width="10%">创建者</th>
<th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学习人数</th>
<th width="15%">fork版的学习人数</th>
<th width="10%">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
<tbody>
<%
total_myshixun_count = 0
total_forked_myshixun_count = 0
%>
<% @shixuns.each do |shixun| %>
<%
total_myshixun_count += shixun.myshixuns_count
total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i
%>
<tr>
<td width="10%"><%= shixun.creator.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to shixun_path(shixun), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 410px;"><%= shixun.name %></span>
<% end %>
<% if shixun.fork_from.blank? %>
<span class="connectTag ml10">原创</span>
<% end %>
</td>
<td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td>
<td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td>
<th width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></th>
<td width="15%">--</td>
</tr>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @shixuns.size %></th>
<th width="10%"><%= total_myshixun_count %></th>
<th width="15%"><%= total_forked_myshixun_count %></th>
<th width="10%"><%= @myshixun_count_map.values.reduce(:+) %></th>
<th width="15%">--</th>
</tr>
</tfoot>
</table>
</div>
<div class="edu-back-white mb20">
<p class="pt20 pb20 font-16"><span class="modalTitle">翻转课堂</span></p>
<table width="100%" class="tBodyScroll edu-txt-center" cellpadding="0" cellspacing="0">
<thead class="lastPart">
<tr>
<th width="10%">创建者</th>
<th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学生数量</th>
<th width="15%">发布的实训作业数量</th>
<th width="10%">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
<tbody>
<%
total_members_count = 0
total_shixun_homework_count = 0
%>
<% @courses.each do |course| %>
<%
total_members_count += course.members_count.to_i
total_shixun_homework_count += course['shixun_homework_count'].to_i
%>
<tr>
<td width="10%"><%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to course_path(course), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 480px;"><%= course.name %></span>
<% end %>
</td>
<td width="10%"><%= course.members_count %></td>
<td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td>
<th width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></th>
<td width="15%">--</td>
</tr>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @courses.size %></th>
<th width="10%"><%= total_members_count %></th>
<th width="15%"><%= total_shixun_homework_count %></th>
<th width="10%"><%= @course_myshixun_map.values.reduce(:+) %></th>
<th width="15%">--</th>
</tr>
</tfoot>
</table>
</div>
</div>
<script>
$(function(){
if($(".tBodyScroll tbody").get(0).scrollHeight > 420){
$(".tBodyScroll thead").addClass("lastPart");
$(".tBodyScroll tfoot").addClass("tfootLastPart");
}else{
$(".tBodyScroll thead").removeClass("lastPart");
$(".tBodyScroll tfoot").removeClass("tfootLastPart");
}
})
</script>

@ -1,94 +0,0 @@
<div class="educontent mb50">
<p class="edu-back-white mb20 padding30 mt10 clearfix lineh-20">
<span class="color-grey-3 font-18 fl">战队详情</span>
<a href="javascript:void(0)" class="color-grey-9 fr">返回</a>
</p>
<div class="edu-back-white mb20">
<p class="pt20 pb20 font-16"><span class="modalTitle">实训项目</span></p>
<table width="100%" class="tBodyScroll edu-txt-center" cellpadding="0" cellspacing="0">
<thead class="lastPart">
<tr>
<th width="10%">创建者</th>
<th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学习人数</th>
<th width="15%">fork版的学习人数</th>
<th width="10%">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
<tbody>
<tr>
<td width="10%">张三</td>
<td width="40%" class="edu-txt-left">
<span class="task-hide fl" style="max-width: 410px;">MySQL数据库编程开发实训基础入门篇)MySQL数据库编程开发实训基础入门篇)</span>
<span class="connectTag">原创</span>
</td>
<td width="10%">1545</td>
<td width="15%">1246</td>
<th width="10%">111</th>
<td width="15%">54987</td>
</tr>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left">6</th>
<th width="10%">12万</th>
<th width="15%">11</th>
<th width="10%">22</th>
<th width="15%">33</th>
</tr>
</tfoot>
</table>
</div>
<div class="edu-back-white mb20">
<p class="pt20 pb20 font-16"><span class="modalTitle">翻转课堂</span></p>
<table width="100%" class="tBodyScroll edu-txt-center" cellpadding="0" cellspacing="0">
<thead class="lastPart">
<tr>
<th width="10%">创建者</th>
<th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学生数量</th>
<th width="15%">发布的实训作业数量</th>
<th width="10%">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
<tbody>
<tr>
<td width="10%">张三</td>
<td width="40%" class="edu-txt-left">
<span class="task-hide fl" style="max-width: 480px;">MySQL数据库编程开发实训基础入门篇)MySQL数据库编程开发实训基础入门篇)</span>
</td>
<td width="10%">1545</td>
<td width="15%">1246</td>
<th width="10%">111</th>
<td width="15%">54987</td>
</tr>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left">6</th>
<th width="10%">12万</th>
<th width="15%">11</th>
<th width="10%">22</th>
<th width="15%">33</th>
</tr>
</tfoot>
</table>
</div>
</div>
<script>
$(function(){
if($(".tBodyScroll tbody").get(0).scrollHeight > 420){
$(".tBodyScroll thead").addClass("lastPart");
$(".tBodyScroll tfoot").addClass("tfootLastPart");
}else{
$(".tBodyScroll thead").removeClass("lastPart");
$(".tBodyScroll tfoot").removeClass("tfootLastPart");
}
})
</script>

@ -46,7 +46,7 @@
<a href="<%= charts_competition_path(@competition) %>" >排行榜</a>
</li>
<% when '报名' %>
<li class="<%= params[:action] == 'enroll' ? 'active' : '' %>">
<li class="<%= params[:action] == 'enroll' || (params[:controller] == 'competition_teams' && params[:action] == 'show') ? 'active' : '' %>">
<a href="<%= enroll_competition_path(@competition) %>">报名</a>
</li>
<% else %>

@ -99,7 +99,7 @@
<% end %>
<a href="javascript:void(0)" class="enrollOperation">进入大赛</a>
<% if @competition.identifier == 'gcc-course-2019' %>
<%= link_to '战队详情', competition_team_path(id: @competition.id),:class => "enrollOperation" %>
<%= link_to '战队详情', competition_team_path(id: team.id), class: 'enrollOperation' %>
<% end %>
</li>
<% end %>

@ -2,6 +2,7 @@
<% if @competitions.count > 0 %>
<div class="clearfix competitionsList">
<% @competitions.each do |competition| %>
<% if competition.status? %>
<div class="competitionsList-item mb20">
<div class="edu-back-white">
<a href="<%= competition_path(competition) %>" class="competition-Img" target="_blank">
@ -67,6 +68,23 @@
</p>
</div>
</div>
<% elsif competition.published_at.present? %>
<div class="competitionsList-item mb20">
<div class="edu-back-white">
<a href="javascript:void(0)" class="competition-Img">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt20 pl20 mb10 clearfix">
<a href="javascript:void(0)" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">即将发布</span>
</div>
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20"></p>
</div>
</div>
<% end %>
<% end %>
</div>
<% else %>

@ -0,0 +1 @@
notice_box_redirect('<%= competition_managements_path %>', '发布成功')

@ -65,6 +65,10 @@
<a href="javascript:void(0)" class="mr10 none" onclick="cancel_edit(this)">取消</a>
<a href="javascript:void(0)" class="mr10 none" onclick="update_competition(<%= competition.id %>)">保存</a>
<a id="competition_status_<%= competition.id %>" data-remote="true" href="<%= online_switch_competition_path(competition) %>" class="mr10"><%= competition.status ? "下架" : "上架" %></a>
<% if !competition.status? && competition.published_at.blank? %>
<%= link_to '发布', publish_competition_path(competition), class: 'mr10', method: :post, remote: true %>
<% end %>
</td>
</tr>
<% end %>

@ -260,6 +260,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'send_message'
get 'export_chart_score'
post 'competition_images'
post 'publish'
end
collection do
post 'new_competition'

@ -0,0 +1,5 @@
class AddPublishedAtToCompetitions < ActiveRecord::Migration
def change
add_column :competitions, :published_at, :datetime
end
end
Loading…
Cancel
Save