Merge branches 'dev_aliyun' and 'develop' of https://bdgit.educoder.net/Hjqreturn/educoder into develop
commit
5dd5721e66
@ -0,0 +1,18 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-subject-modal', function(){
|
||||
var $modal = $('.modal.admin-edit-subject-modal');
|
||||
var $form = $modal.find('form.admin-edit-subject-form');
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize()
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
@ -0,0 +1,107 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-subjects-index-page').length > 0) {
|
||||
var $form = $('.subject-list-form');
|
||||
|
||||
// ************** 学校选择 *************
|
||||
$form.find('.school-select').select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '请选择创建者单位',
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
delay: 500,
|
||||
url: '/api/schools/for_option.json',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.schools }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function(){
|
||||
$form.find('select[name="status"]').val('');
|
||||
$form.find('.school-select').val('').trigger('change');
|
||||
$form.find('input[name="keyword"]').val('');
|
||||
$form.find('#homepage_show').attr('checked', false);
|
||||
$form.find('#excellent').attr('checked', false);
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
})
|
||||
|
||||
// 上传图片
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $imageElement = $('.subject-image-' + data.source_id);
|
||||
$imageElement.attr('src', data.url);
|
||||
$imageElement.show();
|
||||
$imageElement.next().html('重新上传');
|
||||
})
|
||||
|
||||
// 定义状态切换监听事件
|
||||
var defineStatusChangeFunc = function(doElement, undoElement, url, callback){
|
||||
$('.subject-list-container').on('click', doElement, function(){
|
||||
var $doAction = $(this);
|
||||
var $undoAction = $doAction.siblings(undoElement);
|
||||
|
||||
var subjectId = $doAction.data('id');
|
||||
customConfirm({
|
||||
content: '确认进行该操作吗?',
|
||||
ok: function(){
|
||||
$.ajax({
|
||||
url: '/admins/subjects/' + subjectId + url,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function() {
|
||||
show_success_flash();
|
||||
$doAction.hide();
|
||||
$undoAction.show();
|
||||
if(callback && typeof callback === "function"){
|
||||
callback(subjectId, url);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// 隐藏与取消隐藏
|
||||
defineStatusChangeFunc('.hide-action', '.active-action', '/hide');
|
||||
defineStatusChangeFunc('.active-action', '.hide-action', '/cancel_hide');
|
||||
|
||||
// 首页展示与取消首页展示
|
||||
var homepageShowCallback = function(subjectId, url){
|
||||
var $subjectItem = $('.subject-list-container').find('.subject-item-' + subjectId);
|
||||
|
||||
if(url === '/homepage_show'){
|
||||
$subjectItem.find('.homepage-show-badge').show();
|
||||
} else {
|
||||
$subjectItem.find('.homepage-show-badge').hide();
|
||||
}
|
||||
}
|
||||
defineStatusChangeFunc('.homepage-show-action', '.homepage-hide-action', '/homepage_show', homepageShowCallback);
|
||||
defineStatusChangeFunc('.homepage-hide-action', '.homepage-show-action', '/cancel_homepage_show', homepageShowCallback);
|
||||
|
||||
// 设为金课与取消金课
|
||||
var excellentCallback = function(subjectId, url){
|
||||
var $subjectItem = $('.subject-list-container').find('.subject-item-' + subjectId);
|
||||
|
||||
if(url === '/excellent'){
|
||||
$subjectItem.find('.excellent-badge').show();
|
||||
} else {
|
||||
$subjectItem.find('.excellent-badge').hide();
|
||||
}
|
||||
}
|
||||
defineStatusChangeFunc('.excellent-action', '.cancel-excellent-action', '/excellent', excellentCallback);
|
||||
defineStatusChangeFunc('.cancel-excellent-action', '.excellent-action', '/cancel_excellent', excellentCallback);
|
||||
}
|
||||
});
|
@ -0,0 +1,71 @@
|
||||
class Admins::SubjectsController < Admins::BaseController
|
||||
def index
|
||||
default_sort('created_at', 'desc')
|
||||
|
||||
subjects = Admins::SubjectQuery.call(params)
|
||||
@subjects = paginate subjects.includes(:repertoire, :subject_level_system, user: { user_extension: :school })
|
||||
end
|
||||
|
||||
def edit
|
||||
@subject = current_subject
|
||||
end
|
||||
|
||||
def update
|
||||
current_subject.update!(update_params)
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to admins_subjects_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
current_subject.destroy!
|
||||
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
# 隐藏
|
||||
def hide
|
||||
current_subject.update!(hidden: true)
|
||||
render_ok
|
||||
end
|
||||
|
||||
# 展示
|
||||
def cancel_hide
|
||||
current_subject.update!(hidden: false)
|
||||
render_ok
|
||||
end
|
||||
|
||||
# 设为主页展示
|
||||
def homepage_show
|
||||
current_subject.update!(homepage_show: true)
|
||||
render_ok
|
||||
end
|
||||
|
||||
# 取消主页展示
|
||||
def cancel_homepage_show
|
||||
current_subject.update!(homepage_show: false)
|
||||
render_ok
|
||||
end
|
||||
|
||||
# 设为金课
|
||||
def excellent
|
||||
current_subject.update!(excellent: true)
|
||||
render_ok
|
||||
end
|
||||
|
||||
# 取消金课
|
||||
def cancel_excellent
|
||||
current_subject.update!(excellent: false)
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_subject
|
||||
@_current_subject ||= Subject.find(params[:id])
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:subject).permit(:repertoire_id, :subject_level_system_id, :student_count)
|
||||
end
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
module Admins::SubjectsHelper
|
||||
def display_subject_status(subject)
|
||||
style =
|
||||
case subject.status
|
||||
when 0 then 'text-secondary'
|
||||
when 1 then 'text-warning'
|
||||
when 2 then 'text-success'
|
||||
end
|
||||
raw content_tag(:span, t("subject.status.#{subject.status}"), class: style)
|
||||
end
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
class CompetitionManager < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :competition
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class SubjectLevelSystem < ApplicationRecord
|
||||
default_scope { order(level: :asc) }
|
||||
|
||||
has_many :subjects, dependent: :nullify
|
||||
end
|
@ -0,0 +1,45 @@
|
||||
class Admins::SubjectQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :created_at, default_by: :created_at, default_direction: :desc, default_table: 'subjects'
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
subjects = Subject.all
|
||||
|
||||
# 状态过滤
|
||||
status =
|
||||
case params[:status].to_s.strip
|
||||
when 'pending' then 0
|
||||
when 'applying' then 1
|
||||
when 'published' then 2
|
||||
end
|
||||
subjects = subjects.where(status: status) if status
|
||||
|
||||
# 创建者单位
|
||||
if params[:school_id].present?
|
||||
subjects = subjects.joins(user: :user_extension).where(user_extensions: { school_id: params[:school_id] })
|
||||
end
|
||||
|
||||
# 首页展示、金课
|
||||
%i[homepage_show excellent].each do |column|
|
||||
if params[column].present? && params[column].to_s == 'true'
|
||||
subjects = subjects.where(column => true)
|
||||
end
|
||||
end
|
||||
|
||||
# 关键字
|
||||
keyword = params[:keyword].to_s.strip
|
||||
if keyword
|
||||
sql = 'CONCAT(lastname, firstname) LIKE :keyword OR subjects.name LIKE :keyword'
|
||||
subjects = subjects.joins(:user).where(sql, keyword: "%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(subjects, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
$('.admin-modal-container').html("<%= j( render partial: 'admins/subjects/shared/edit_subject_modal', locals: { subject: @subject } ) %>");
|
||||
$('.modal.admin-edit-subject-modal').modal('show');
|
@ -0,0 +1,39 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('课程配置') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container subject-list-form">
|
||||
<%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<div class="form-group mr-1">
|
||||
<label for="status">状态:</label>
|
||||
<% status_options = [['全部', ''], ['编辑中', 'pending'], ['审核中', 'applying'], ['已发布', 'published']] %>
|
||||
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-12 col-md-3">
|
||||
<label for="school_name">单位:</label>
|
||||
<%= select_tag :school_id, options_for_select([''], params[:school_id]), class: 'form-control school-select flex-1' %>
|
||||
</div>
|
||||
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/课程名称检索') %>
|
||||
|
||||
<div class="form-check mr-2">
|
||||
<%= hidden_field_tag(:homepage_show, false, id:'') %>
|
||||
<%= check_box_tag(:homepage_show, true, params[:homepage_show].to_s == 'true', class: 'form-check-input') %>
|
||||
<label class="form-check-label" for="homepage_show">只看首页展示</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mr-2">
|
||||
<%= hidden_field_tag(:excellent, false, id:'') %>
|
||||
<%= check_box_tag(:excellent, true, params[:excellent].to_s == 'true', class: 'form-check-input') %>
|
||||
<label class="form-check-label" for="excellent">只看金课</label>
|
||||
</div>
|
||||
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box subject-list-container">
|
||||
<%= render partial: 'admins/subjects/shared/list', locals: { subjects: @subjects } %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.subject-list-container').html("<%= j( render partial: 'admins/subjects/shared/list', locals: { subjects: @subjects } ) %>");
|
@ -0,0 +1,33 @@
|
||||
<div class="modal fade admin-edit-subject-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">
|
||||
<%= simple_form_for([:admins, subject], html: { class: 'admin-edit-subject-form' }, defaults: { wrapper_html: { class: 'offset-md-1 col-md-10' } }) do |f| %>
|
||||
<%= f.input :repertoire_id, label: '技术体系:' do %>
|
||||
<% repertoire_options = Repertoire.order('CONVERT(name USING gbk) COLLATE gbk_chinese_ci ASC').map{|r| [r.name, r.id]} %>
|
||||
<%= f.select :repertoire_id, [['请选择', '']] + repertoire_options, {}, class: 'form-control' %>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :subject_level_system_id, label: '等级体系:' do %>
|
||||
<% level_options = SubjectLevelSystem.all.map{|r| [r.name, r.id]} %>
|
||||
<%= f.select :subject_level_system_id, [['请选择', '']] + level_options, {}, class: 'form-control' %>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :student_count, as: :integer, label: '开课人数:' %>
|
||||
|
||||
<div class="error text-danger"></div>
|
||||
<% end %>
|
||||
</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,73 @@
|
||||
<table class="table table-hover text-center subject-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="14%" class="text-left">名称</th>
|
||||
<th width="6%">阶段数</th>
|
||||
<th width="6%">实训数</th>
|
||||
<th width="8%">技术体系</th>
|
||||
<th width="8%">等级体系</th>
|
||||
<th width="8%">封面</th>
|
||||
<th width="7%">创建者</th>
|
||||
<th width="10%">单位</th>
|
||||
<th width="8%">开课人数</th>
|
||||
<th width="10%"><%= sort_tag('创建时间', name: 'created_at', path: admins_subjects_path) %></th>
|
||||
<th width="7%">状态</th>
|
||||
<th width="15%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if subjects.present? %>
|
||||
<% subjects.each do |subject| %>
|
||||
<tr class="subject-item-<%= subject.id %>">
|
||||
<td class="text-left">
|
||||
<%= link_to(subject.name, subject_path(subject), target: '_blank') %>
|
||||
<span class="badge badge-pill badge-success homepage-show-badge" style="<%= subject.homepage_show? ? '' : 'display:none' %>">首页</span>
|
||||
<span class="badge badge-pill badge-info excellent-badge" style="<%= subject.excellent? ? '' : 'display:none' %>">金课</span>
|
||||
</td>
|
||||
<td><%= subject.stages_count %></td>
|
||||
<td><%= subject.shixuns_count %></td>
|
||||
<td><%= display_text subject.repertoire&.name %></td>
|
||||
<td><%= display_text subject.subject_level_system&.name %></td>
|
||||
<td>
|
||||
<% image_exists = Util::FileManage.exists?(subject) %>
|
||||
<%= image_tag(image_exists ? Util::FileManage.source_disk_file_url(subject) : '', height: 40, class: "w-100 preview-image subject-image-#{subject.id}", style: image_exists ? '' : 'display:none') %>
|
||||
<%= javascript_void_link image_exists ? '重新上传' : '上传图片', class: 'action upload-image-action', data: { source_id: subject.id, source_type: 'Subject', toggle: 'modal', target: '.admin-upload-file-modal' } %>
|
||||
</td>
|
||||
<td><%= subject.user.real_name %></td>
|
||||
<td><%= subject.user.school_name %></td>
|
||||
<td><%= subject.student_count %></td>
|
||||
<td><%= subject.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
<td>
|
||||
<%= display_subject_status(subject) %>
|
||||
</td>
|
||||
<td class="action-container">
|
||||
<%= link_to('编辑', edit_admins_subject_path(subject), remote: true, class: 'edit-action') %>
|
||||
|
||||
<%= javascript_void_link('隐藏', class: 'hide-action', data: { id: subject.id }, style: subject.hidden? ? 'display:none' : '') %>
|
||||
<%= javascript_void_link('取消隐藏', class: 'active-action', data: { id: subject.id }, style: subject.hidden? ? '' : 'display:none') %>
|
||||
|
||||
<div class="d-inline">
|
||||
<%= javascript_void_link('更多', class: 'action dropdown-toggle', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) %>
|
||||
<div class="dropdown-menu more-action-dropdown">
|
||||
<% if subject.published? %>
|
||||
<%= javascript_void_link('首页展示', class: 'dropdown-item homepage-show-action', data: { id: subject.id }, style: subject.homepage_show? ? 'display:none' : '') %>
|
||||
<%= javascript_void_link('取消首页展示', class: 'dropdown-item homepage-hide-action', data: { id: subject.id }, style: subject.homepage_show? ? '' : 'display:none') %>
|
||||
|
||||
<%= javascript_void_link('选为金课', class: 'dropdown-item excellent-action', data: { id: subject.id }, style: subject.excellent? ? 'display:none' : '') %>
|
||||
<%= javascript_void_link('取消金课', class: 'dropdown-item cancel-excellent-action', data: { id: subject.id }, style: subject.excellent? ? '' : 'display:none') %>
|
||||
<% end %>
|
||||
|
||||
<%= delete_link '删除', admins_subject_path(subject, element: ".subject-item-#{subject.id}"), class: 'dropdown-item delete-subject-action' %>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: subjects } %>
|
||||
<%= render partial: 'admins/shared/modal/upload_file_modal', locals: { title: '上传图片', accept: 'image/*' } %>
|
@ -0,0 +1,7 @@
|
||||
json.course_members @course_members.each do |member|
|
||||
user = member.user
|
||||
json.user_login user.login
|
||||
json.user_name user.real_name
|
||||
# json.course_group member.course_group_name
|
||||
json.total_score member.score
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
json.top_scores @top_scores.each do |cm_score|
|
||||
user = cm_score.user
|
||||
json.user_name user.real_name
|
||||
json.user_login user.login
|
||||
json.avatar_url url_to_avatar(user)
|
||||
end
|
@ -0,0 +1,13 @@
|
||||
json.course_members @course_members.each do |member|
|
||||
user = member.user
|
||||
json.user_login user.login
|
||||
json.user_name user.real_name
|
||||
json.course_group member.course_group_name
|
||||
json.common_score member.common_score
|
||||
json.group_score member.group_score
|
||||
json.practice_score member.practice_score
|
||||
json.exercise_score member.exercise_score
|
||||
json.graduation_score member.graduation_score
|
||||
json.total_score member.score
|
||||
json.rank @rank if @user_course_identity == Course::STUDENT
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
'zh-CN':
|
||||
subject:
|
||||
status:
|
||||
'0': 编辑中
|
||||
'1': 审核中
|
||||
'2': 已发布
|
@ -0,0 +1,10 @@
|
||||
class CreateCompetitionManagers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :competition_managers do |t|
|
||||
t.references :user
|
||||
t.references :competition
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class AddStatisticsToCourseModule < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
Course.includes(:course_modules).all.each do |course|
|
||||
CourseModule.create!(course_id: course.id, module_type: "statistics", hidden:0, module_name: "统计", position: course.course_modules.pluck(:position).max + 1)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
class InitTrustieConfig < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
hash = {"trustie_api_token" => "", "trustie_api_url" => ""}
|
||||
hash.each { |key, value|
|
||||
EduSetting.find_or_create_by(name: key, value: value)
|
||||
}
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 303 KiB After Width: | Height: | Size: 306 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,67 @@
|
||||
.height-60{
|
||||
line-height: 60px;
|
||||
height:60px;
|
||||
background:rgba(255,208,88,1);
|
||||
border-radius:4px 4px 0px 0px;
|
||||
}
|
||||
.height-40{
|
||||
line-height: 40px;
|
||||
height:40px;
|
||||
background:rgba(224,229,234,1);
|
||||
border-radius:4px 0px 0px 0px;
|
||||
}
|
||||
.height-20{
|
||||
line-height: 20px;
|
||||
height:20px;
|
||||
background:rgba(229,168,102,1);
|
||||
border-radius:0px 4px 0px 0px;
|
||||
}
|
||||
.Statisticscenter{
|
||||
text-align: center;
|
||||
}
|
||||
.Statisticscenter div:nth-child(1){
|
||||
margin-top: 5px;
|
||||
font-size:12px;
|
||||
color:rgba(51,51,51,1);
|
||||
}
|
||||
|
||||
.Statisticscenter div:nth-child(2){
|
||||
margin-top: 5px;
|
||||
font-size: 12px;
|
||||
color: rgba(153,153,153,1);
|
||||
}
|
||||
|
||||
.rankingss {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.rankingss a img {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0px 0px 12px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.huangguans{
|
||||
position: absolute;
|
||||
top: -30px;
|
||||
left: 72px;
|
||||
}
|
||||
|
||||
.relatives{
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.statisticsTabs{
|
||||
padding: 30px;
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
||||
.statisticsTabs .ant-tabs-tab{
|
||||
height: 80px;
|
||||
text-align: center;
|
||||
line-height: 61px;
|
||||
font-size: 16px;
|
||||
color: rgba(80,145,255,1);
|
||||
}
|
@ -0,0 +1,324 @@
|
||||
import React,{ Component } from "react";
|
||||
import {Table, Pagination,Tooltip,Spin, Row, Col ,Tabs} from "antd";
|
||||
import { WordsBtn,on, off, trigger ,getImageUrl} from 'educoder';
|
||||
import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom';
|
||||
import axios from'axios';
|
||||
import './Statistics.css';
|
||||
const { TabPane } = Tabs;
|
||||
class Statistics extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
nd1:60,
|
||||
nd2:40,
|
||||
nd3:20,
|
||||
data:undefined,
|
||||
bomdata:undefined,
|
||||
topisSpin:true,
|
||||
bomisSpin:true,
|
||||
sort:'desc',
|
||||
course_groups:[],
|
||||
page:1
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let {page,group_ids,sort}=this.state;
|
||||
let courseId=this.props.match.params.coursesId;
|
||||
let url=`/courses/${courseId}/statistics.json`;
|
||||
axios.get(url).then((result) => {
|
||||
if (result) {
|
||||
this.setState({
|
||||
data:result.data.top_scores,
|
||||
topisSpin:false
|
||||
})
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
this.setState({
|
||||
topisSpin:false,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
let courseurl=`/courses/${courseId}/all_course_groups.json`;
|
||||
axios.get(courseurl).then((result) => {
|
||||
if (result) {
|
||||
this.setState({
|
||||
course_groups:result.data.course_groups
|
||||
})
|
||||
let list=result.data.course_groups;
|
||||
if(list.length>0){
|
||||
this.setState({
|
||||
group_ids:[list[0].id],
|
||||
})
|
||||
this.getwork_scoredata(page,[list[0].id],sort);
|
||||
}
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
getwork_scoredata=(page,group_ids,sort)=>{
|
||||
let courseId=this.props.match.params.coursesId;
|
||||
let url=`/courses/${courseId}/work_score.json`;
|
||||
let data={
|
||||
limit:20,
|
||||
page:page,
|
||||
group_ids:group_ids,
|
||||
sort:sort
|
||||
}
|
||||
axios.get(url,{params:
|
||||
data
|
||||
}).then((result) => {
|
||||
if (result) {
|
||||
this.setState({
|
||||
bomdata:result.data.course_members,
|
||||
bomisSpin:false
|
||||
})
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
this.setState({
|
||||
bomisSpin:false,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
callback=(key)=>{
|
||||
console.log(key);
|
||||
}
|
||||
|
||||
render(){
|
||||
let {nd1,nd2,nd3,data,bomdata,course_groups}=this.state;
|
||||
let course_grouptype=false
|
||||
if(this.props&&this.props.course_modules!=undefined){
|
||||
{this.props&&this.props.course_modules.map((item,key)=>{
|
||||
if(item.type==="course_group"){
|
||||
course_grouptype=true
|
||||
}
|
||||
})}
|
||||
}
|
||||
|
||||
// const columns = [
|
||||
// {
|
||||
// title: 'Name',
|
||||
// dataIndex: 'name',
|
||||
// sorter: true,
|
||||
// render: name => `${name.first} ${name.last}`,
|
||||
// width: '20%',
|
||||
// },
|
||||
// {
|
||||
// title: 'Gender',
|
||||
// dataIndex: 'gender',
|
||||
// filters: course_groups,
|
||||
// width: '20%',
|
||||
// },
|
||||
// {
|
||||
// title: 'Email',
|
||||
// dataIndex: 'email',
|
||||
// },
|
||||
// ];
|
||||
|
||||
|
||||
// console.log(bomdata)
|
||||
|
||||
|
||||
//common_score: 0
|
||||
// course_group: "威风威风急急急"
|
||||
// exercise_score: "0.0"
|
||||
// graduation_score: 0
|
||||
// group_score: 0
|
||||
// practice_score: 3232
|
||||
// total_score: 3232
|
||||
// user_login: "p40793521"
|
||||
// user_name: "李明霞"
|
||||
|
||||
|
||||
return(
|
||||
<React.Fragment >
|
||||
<div>
|
||||
|
||||
<div className="edu-back-white">
|
||||
<Spin size="large" spinning={this.state.topisSpin}>
|
||||
<p className="clearfix padding30">
|
||||
<Row gutter={24}>
|
||||
<Col>
|
||||
明星学员
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row type="flex" justify="center" align="bottom">
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===3){
|
||||
return(
|
||||
<Col span={3}>
|
||||
<li className="pr rankingss">
|
||||
<a href={`/users/${item.user_login}`} className="color-dark">
|
||||
<img src={getImageUrl(`images/${item.avatar_url}`)}/>
|
||||
</a>
|
||||
</li>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
|
||||
})}
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===1){
|
||||
return(
|
||||
<Col span={5}>
|
||||
<li className="pr rankingss">
|
||||
<a href={`/users/${item.user_login}`} className="color-dark">
|
||||
<img src={getImageUrl(`images/${item.avatar_url}`)} className={"mb10"}/>
|
||||
</a>
|
||||
</li>
|
||||
<Col className={`height-${nd2}`}>
|
||||
|
||||
</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
|
||||
})}
|
||||
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===0){
|
||||
return(
|
||||
<Col span={5} className={"relatives"}>
|
||||
<li className="pr rankingss">
|
||||
<img src="https://test-newweb.educoder.net/images/educoder/huangguan.png" className="huangguans mb5" />
|
||||
<a href={`/users/${item.user_login}`} className="color-dark">
|
||||
<img src={getImageUrl(`images/${item.avatar_url}`)} className={"mb10 mt5"}/>
|
||||
</a>
|
||||
</li>
|
||||
<Col className={`height-${nd1}`}>
|
||||
|
||||
</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
|
||||
})}
|
||||
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===2){
|
||||
return(
|
||||
<Col span={5}>
|
||||
<li className="pr rankingss">
|
||||
<a href={`/users/${item.user_login}`} className="color-dark">
|
||||
<img src={getImageUrl(`images/${item.avatar_url}`)} className={"mb10"}/>
|
||||
</a>
|
||||
</li>
|
||||
<Col className={`height-${nd3}`}>
|
||||
|
||||
</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
|
||||
})}
|
||||
|
||||
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===4){
|
||||
return(
|
||||
<Col span={3}>
|
||||
<li className="pr rankingss">
|
||||
<a href={`/users/${item.user_login}`} className="color-dark">
|
||||
<img src={getImageUrl(`images/${item.avatar_url}`)}/>
|
||||
</a>
|
||||
</li>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
|
||||
})}
|
||||
|
||||
|
||||
</Row>
|
||||
|
||||
|
||||
<Row className="mt10" type="flex" justify="center" align="bottom">
|
||||
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===3){
|
||||
return(
|
||||
<Col span={3} className={"Statisticscenter"}>
|
||||
<Col>{item.user_name}</Col>
|
||||
<Col>4th</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
})}
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===1){
|
||||
return(
|
||||
<Col span={5} className={"Statisticscenter"}>
|
||||
<Col>{item.user_name}</Col>
|
||||
<Col>2th</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
})}
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===0){
|
||||
return(
|
||||
<Col span={5} className={"Statisticscenter"}>
|
||||
<Col>{item.user_name}</Col>
|
||||
<Col>1th</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
})}
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===2){
|
||||
return(
|
||||
<Col span={5} className={"Statisticscenter"}>
|
||||
<Col>{item.user_name}</Col>
|
||||
<Col>3th</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
})}
|
||||
{data&&data.map((item,key)=>{
|
||||
if(key===4){
|
||||
return(
|
||||
<Col span={3} className={"Statisticscenter"}>
|
||||
<Col>{item.user_name}</Col>
|
||||
<Col>5th</Col>
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
})}
|
||||
|
||||
</Row>
|
||||
</p>
|
||||
</Spin>
|
||||
</div>
|
||||
|
||||
<div className="mt20 edu-back-white">
|
||||
<Spin size="large" spinning={this.state.bomisSpin}>
|
||||
<Tabs className="statisticsTabs" defaultActiveKey="1" onChange={this.callback}>
|
||||
<TabPane tab="学习成绩" key="1" className={"statisticsTabs1"}>
|
||||
{/*<Table*/}
|
||||
{/*columns={columns}*/}
|
||||
{/*dataSource={bomdata}*/}
|
||||
{/*onChange={this.handleTableChange}*/}
|
||||
{/*/>*/}
|
||||
</TabPane>
|
||||
<TabPane tab="课堂活跃度" key="2">
|
||||
Content of Tab Pane 2
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Spin>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default Statistics;
|
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 303 KiB After Width: | Height: | Size: 306 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue