Merge branch 'dev_aliyun' into educoder

dev_aliyun
daiao 5 years ago
commit a3d84622cb

@ -14,6 +14,10 @@ class CompetitionTeamsController < ApplicationController
def show
return render_404 if @competition.identifier != 'gcc-course-2019'
end
def shixun_detail
return render_404 if @competition.identifier != 'gcc-course-2019'
@team_user_ids = @team.team_members.pluck(:user_id)
@ -40,13 +44,17 @@ class CompetitionTeamsController < ApplicationController
@forked_course_count_map[forked_shixun_map[forked_id]] += course_count
end
@forked_shixun_map = forked_shixun_map
end
def course_detail
return render_404 if @competition.identifier != 'gcc-course-2019'
@team_user_ids = @team.team_members.pluck(:user_id)
# 课堂
student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql
subquery = StudentWork.where('homework_common_id = hcs.id')
.select('sum(compelete_status !=0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
.select('sum(compelete_status !=0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01'))
.where('courses.created_at <= ?', @competition.end_time)
.where("(#{student_count_subquery}) >= 3")
@ -55,7 +63,7 @@ class CompetitionTeamsController < ApplicationController
.where(course_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').having('shixun_homework_count > 0')
.group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0')
course_ids = @courses.map(&:id)
@course_myshixun_map = Myshixun.joins(student_works: :homework_common)

@ -2084,7 +2084,7 @@ end
@school_id = params[:school_id]
if params[:school_id] && params[:school_id] != ''
@courses = @courses.joins("join user_extensions ue on courses.tea_id = ue.user_id").where("ue.school_id = #{params[:school_id]}")
@courses = @courses.where(school_id: params[:school_id])
end
if params[:homepage_show]
@ -4206,7 +4206,7 @@ end
sheet1[count_row, 5] = show_shixun_mirror(shixun)
sheet1[count_row, 6] = shixun.fork_identifier
sheet1[count_row, 7] = shixun.challenges.count
sheet1[count_row, 8] = Setting.server_url + shixun_path(shixun)
sheet1[count_row, 8] = Setting.server_url + shixun_path(shixun).sub("/", "")
count_row += 1
end
book.write xls_report

@ -20,13 +20,13 @@
<%= course_managers course.teachers %>
</td>
<td class="edu-txt-center"><%= course.evaluating_count %></td>
<td class="edu-txt-center"><%= @student_count.fetch(course.id, 0) %></td>
<td class="edu-txt-center"><%= @shixun_work_count.fetch(course.id, 0) %></td>
<td class="edu-txt-center"><%= @attachment_count.fetch(course.id, 0) %></td>
<td class="edu-txt-center"><%= @message_count.fetch(course.id, 0) %></td>
<td class="edu-txt-center"><%= @exercise_count.fetch(course.id, 0) + @poll_count.fetch(course.id, 0) + @other_work_count.fetch(course.id, 0) %></td>
<td class="edu-txt-center"><%= course.student_count.to_i %></td>
<td class="edu-txt-center"><%= course.hcm_count.to_i %></td>
<td class="edu-txt-center"><%= course.attachments_count.to_i %></td>
<td class="edu-txt-center"><%= course.messages_count.to_i %></td>
<td class="edu-txt-center"><%= course.hcm_nonshixun_count.to_i + course.exercises_count.to_i + course.polls_count.to_i %></td>
<td class="edu-txt-center <%= course.is_end ? "color-grey-98" : "color-orange" %>"><%= course.is_end ? "已结束" : "正在进行" %></td>
<td class="edu-txt-center color-grey-9"><%= format_time @active_time[course.id] %></td>
<td class="edu-txt-center color-grey-9"><%= format_time course.update_time %></td>
</tr>
<% end %>
</tbody>

@ -0,0 +1,52 @@
<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%" data-tip-down="至少完成了1个关卡">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
<tbody>
<%
total_members_count = 0
total_shixun_homework_count = 0
total_course_score = 0
%>
<% @courses.each do |course| %>
<%
total_members_count += course.members_count.to_i
total_shixun_homework_count += course['shixun_homework_count'].to_i
score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0)
total_course_score += score
%>
<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>
<td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></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(:+) || 0 %></th>
<th width="15%"><%= total_course_score %></th>
</tr>
</tfoot>
</table>

@ -0,0 +1,68 @@
<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%" data-tip-down="fork该实训产生的新实训学习总人数">fork版的学习人数</th>
<th width="10%" data-tip-down="至少完成了1个关卡">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
<tbody>
<%
total_myshixun_count = 0
total_forked_myshixun_count = 0
total_shixun_score = 0
%>
<% @shixuns.each do |shixun| %>
<%
total_myshixun_count += shixun.myshixuns_count
total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i
valid_course_count = @course_count_map.fetch(shixun.id, 0)
valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0)
score =
if shixun.fork_from.blank?
500 + 50 * valid_course_count + 10 * valid_student_count
else
100 + 10 * valid_course_count + 5 * valid_student_count
end
@forked_shixun_map.each do |shixun_id, fork_from_id|
next if fork_from_id != shixun.id
score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0)
end
total_shixun_score += score
%>
<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>
<td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></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%"><%= total_shixun_score %></th>
</tr>
</tfoot>
</table>

@ -0,0 +1 @@
$('.competition-detail-course').html("<%= j(render :partial => 'competition_team_detail_course') %>");

@ -0,0 +1 @@
$('.competition-detail-shixun').html("<%= j(render :partial => 'competition_team_detail_shixun') %>");

@ -3,7 +3,7 @@
<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">
<div class="edu-back-white mb20 competition-detail-shixun">
<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">
@ -17,64 +17,22 @@
</tr>
</thead>
<tbody>
<%
total_myshixun_count = 0
total_forked_myshixun_count = 0
total_shixun_score = 0
%>
<% @shixuns.each do |shixun| %>
<%
total_myshixun_count += shixun.myshixuns_count
total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i
valid_course_count = @course_count_map.fetch(shixun.id, 0)
valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0)
score =
if shixun.fork_from.blank?
500 + 50 * valid_course_count + 10 * valid_student_count
else
100 + 10 * valid_course_count + 5 * valid_student_count
end
@forked_shixun_map.each do |shixun_id, fork_from_id|
next if fork_from_id != shixun.id
score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0)
end
total_shixun_score += score
%>
<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>
<td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></td>
</tr>
<% end %>
<tr><td colspan="100" style="height: 300px;text-align: center">加载中...</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"><%= @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%"><%= total_shixun_score %></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>
</tfoot>
</table>
</div>
<div class="edu-back-white mb20">
<div class="edu-back-white mb20 competition-detail-course">
<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">
@ -88,41 +46,16 @@
</tr>
</thead>
<tbody>
<%
total_members_count = 0
total_shixun_homework_count = 0
total_course_score = 0
%>
<% @courses.each do |course| %>
<%
total_members_count += course.members_count.to_i
total_shixun_homework_count += course['shixun_homework_count'].to_i
score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0)
total_course_score += score
%>
<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>
<td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></td>
</tr>
<% end %>
<tr><td colspan="100" style="height: 300px;text-align: center">加载中...</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"><%= @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(:+) || 0 %></th>
<th width="15%"><%= total_course_score %></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>
</tfoot>
</table>
@ -131,6 +64,10 @@
<script>
$(function(){
$.ajax({ url: '<%= shixun_detail_competition_team_path(@team) %>', method: 'GET', dataType: 'script' });
$.ajax({ url: '<%= course_detail_competition_team_path(@team) %>', method: 'GET', dataType: 'script' });
if($(".tBodyScroll tbody").get(0).scrollHeight > 420){
$(".tBodyScroll thead").addClass("lastPart");
$(".tBodyScroll tfoot").addClass("tfootLastPart");

@ -283,6 +283,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
resources :competition_teams do
member do
get 'exit_team'
get 'shixun_detail'
get 'course_detail'
end
collection do

Loading…
Cancel
Save