Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
63116768cf
@ -0,0 +1,9 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if($('body.admins-enroll-lists-index-page').length > 0){
|
||||
let search_form = $(".search-form");
|
||||
//导出
|
||||
$(".competition-enroll-list-form").on("click","#enroll-lists-export",function () {
|
||||
window.location.href = "/admins/competitions/"+$(this).attr("data-competition-id")+"/enroll_lists.xls?" + search_form.serialize();
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
class Admins::EnrollListsController < Admins::BaseController
|
||||
|
||||
def index
|
||||
@competition = current_competition
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
enroll_lists = Admins::CompetitionEnrollListQuery.call(@competition, params)
|
||||
|
||||
@params_page = params[:page] || 1
|
||||
@enroll_lists = paginate enroll_lists.preload(competition_team: [:user, :teachers], user: { user_extension: :school })
|
||||
@personal = @competition.personal?
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def current_competition
|
||||
@_current_competition ||= Competition.find(params[:competition_id])
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,40 @@
|
||||
class Admins::CompetitionEnrollListQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :competition, :params
|
||||
|
||||
sort_columns :created_at, :competition_team_id, default_by: :created_at, default_direction: :desc
|
||||
|
||||
def initialize(competition, params)
|
||||
@competition = competition
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
members = competition.team_members
|
||||
only_teacher = competition.competition_staffs.count == 1 && competition.competition_staffs.first.category == 'teacher'
|
||||
members = members.where("team_members.is_teacher = 0") unless only_teacher # 只有老师报名时才显示老师,此时老师作为队员
|
||||
|
||||
|
||||
school = params[:school].to_s.strip
|
||||
if school.present?
|
||||
school_ids = School.where("schools.name like ?", "%#{school}%").pluck(:id)
|
||||
school_ids = school_ids.size == 0 ? "(-1)" : "(" + school_ids.join(",") + ")"
|
||||
members = members.joins(user: :user_extension).where("user_extensions.school_id in #{school_ids}")
|
||||
end
|
||||
|
||||
location = params[:location].to_s.strip
|
||||
if location.present?
|
||||
members = members.joins(user: { user_extension: :school }).where("schools.province like ?", "%#{location}%")
|
||||
end
|
||||
|
||||
# 关键字模糊查询
|
||||
keyword = params[:keyword].to_s.strip
|
||||
if keyword.present?
|
||||
members = members.joins(:competition_team)
|
||||
.where('competition_teams.name LIKE :keyword', keyword: "%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(members, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
@ -0,0 +1 @@
|
||||
$('.competitions-list-container').html("<%= j( render partial: 'admins/competitions/shared/list', locals: { competitions: @competitions } ) %>");
|
@ -0,0 +1,4 @@
|
||||
var page_no = $("#competition-item-<%= @competition.id %>").children(":first").html();
|
||||
$("#competition-item-<%= @competition.id %>").html("<%= j render partial: "admins/competitions/shared/td", locals: {competition: @competition, page_no: 1} %>");
|
||||
$("#competition-item-<%= @competition.id %>").children(":first").html(page_no);
|
||||
show_success_flash();
|
@ -0,0 +1,4 @@
|
||||
var page_no = $("#competition-item-<%= @competition.id %>").children(":first").html();
|
||||
$("#competition-item-<%= @competition.id %>").html("<%= j render partial: "admins/competitions/shared/td", locals: {competition: @competition, page_no: 1} %>");
|
||||
$("#competition-item-<%= @competition.id %>").children(":first").html(page_no);
|
||||
show_success_flash();
|
@ -0,0 +1,28 @@
|
||||
<div class="modal fade admin-create-competition-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">新增竞赛</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="admin-create-competition-form" data-url="<%= admins_competitions_path %>">
|
||||
<div class="form-group d-flex">
|
||||
<label for="new_mirror_id" class="col-form-label">竞赛名称:</label>
|
||||
<div class="w-75 d-flex flex-column">
|
||||
<%= text_field_tag(:competition_name, nil, class: 'form-control', placeholder: '请输入竞赛名称') %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="error text-danger"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary submit-btn">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,4 @@
|
||||
var page_no = $("#competition-item-<%= @competition.id %>").children(":first").html();
|
||||
$("#competition-item-<%= @competition.id %>").html("<%= j render partial: "admins/competitions/shared/td", locals: {competition: @competition, page_no: 1} %>");
|
||||
$("#competition-item-<%= @competition.id %>").children(":first").html(page_no);
|
||||
show_success_flash();
|
@ -0,0 +1,42 @@
|
||||
<table class="table text-center shixun-settings-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="4%" class="text-left">序号</th>
|
||||
<th width="6%"><%= sort_tag('战队ID', name: 'competition_team_id', path: admins_competition_enroll_lists_path(@competition)) %></th>
|
||||
<th width="12%">战队名称</th>
|
||||
<th width="10%">创建者</th>
|
||||
<th width="10%">队员姓名</th>
|
||||
<th width="6%">职业</th>
|
||||
<th width="12%">学号</th>
|
||||
<th width="10%">队员学校</th>
|
||||
<th width="6%">地区</th>
|
||||
<th width="16%">指导老师</th>
|
||||
<th width="8%"><%= sort_tag('报名时间', name: 'created_at', path: admins_competition_enroll_lists_path(@competition)) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if enroll_lists.present? %>
|
||||
<% enroll_lists.each_with_index do |member, index| %>
|
||||
<tr id="competition-team-member-<%= member.id %>">
|
||||
<% team = member.competition_team %>
|
||||
<% page_no = list_index_no(@params_page.to_i, index) %>
|
||||
<td><%= page_no %></td>
|
||||
<td><%= member.competition_team_id %></td>
|
||||
<td><%= @personal ? "--" : team.name %></td>
|
||||
<td><%= team.user.real_name %></td>
|
||||
<td><%= member.user.real_name %></td>
|
||||
<td><%= member.user.identity %></td>
|
||||
<td><%= member.user.student_id %></td>
|
||||
<td><%= member.user.school_name %></td>
|
||||
<td><%= member.user.school_province %></td>
|
||||
<td><%= @personal ? "--" : team.teachers_info %></td>
|
||||
<td><%= member.created_at.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: enroll_lists } %>
|
@ -0,0 +1,33 @@
|
||||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('竞赛列表', admins_competitions_path)
|
||||
add_admin_breadcrumb(@competition.name)
|
||||
end
|
||||
%>
|
||||
|
||||
<div class="box search-form-container flex-column mb-0 pb-0 competition-enroll-list-form">
|
||||
<ul class="nav nav-tabs w-100 search-form-tabs">
|
||||
<li class="nav-item">
|
||||
<%= link_to '报名列表', admins_competition_enroll_lists_path(@competition), class: "nav-link search-form-tab active" %>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<%= link_to '获奖证书审批', admins_competition_enroll_lists_path(@competition), class: "nav-link search-form-tab" %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="d-flex">
|
||||
<%= form_tag(admins_competition_enroll_lists_path(unsafe_params), method: :get, class: 'form-inline search-form mt-3 flex-1 d-flex', remote: true) do %>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '战队名称检索') %>
|
||||
<%= text_field_tag(:school, params[:school], class: 'form-control col-sm-2 ml-3', placeholder: '队员学校名称检索') %>
|
||||
<%= text_field_tag(:location, params[:location], class: 'form-control col-sm-2 ml-3', placeholder: '队员地区检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<%= link_to "清除", admins_competition_enroll_lists_path(@competition), class: "btn btn-default",'data-disable-with': '清除中...' %>
|
||||
<% end %>
|
||||
|
||||
<a href="javascript:void(0)" class="btn btn-primary mt-3" id="enroll-lists-export" data-competition-id="<%= @competition.id %>" data-disable-with = '导出中...'>导出</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box competition-enroll-list-container">
|
||||
<%= render(partial: 'admins/enroll_lists/list', locals: { enroll_lists: @enroll_lists }) %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.competition-enroll-list-container').html("<%= j( render(partial: 'admins/enroll_lists/list', locals: { enroll_lists: @enroll_lists }) ) %>");
|
@ -0,0 +1,25 @@
|
||||
class MigrateExerciseChallengeScore < ActiveRecord::Migration[5.2]
|
||||
include ExercisesHelper
|
||||
def change
|
||||
exercise = Exercise.find_by(id: 2734)
|
||||
if exercise
|
||||
exercise.exercise_users.where("start_at is not null").each do |exercise_user|
|
||||
if exercise_user.end_at.nil?
|
||||
calculate_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
|
||||
subjective_score = exercise_user.subjective_score
|
||||
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
|
||||
total_score = calculate_score + total_score_subjective_score
|
||||
exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3)
|
||||
puts exercise_user.id
|
||||
else
|
||||
calculate_score = ExerciseShixunAnswer.where(user_id: exercise_user.user_id, exercise_question_id: exercise.exercise_questions.pluck(:id)).pluck(:score).sum
|
||||
subjective_score = exercise_user.subjective_score
|
||||
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
|
||||
total_score = calculate_score + total_score_subjective_score
|
||||
exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) if total_score > exercise_user.score
|
||||
puts exercise_user.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue