From bb2f4cf438672751a2a868d1a42df9bc9dbde450 Mon Sep 17 00:00:00 2001
From: Jasder <2053003901@@qq.com>
Date: Wed, 11 Dec 2019 15:06:04 +0800
Subject: [PATCH] FIX delete colleges
---
.../javascripts/colleges/partner_customers.js | 28 ---
.../colleges/partner_manager_groups.js | 125 -------------
app/assets/javascripts/colleges/statistics.js | 156 ----------------
app/assets/stylesheets/colleges/common.scss | 131 --------------
.../colleges/partner_customers.scss | 5 -
.../colleges/partner_manager_groups.scss | 104 -----------
.../stylesheets/colleges/statistic.scss | 137 --------------
app/controllers/colleges_controller.rb | 171 ------------------
.../colleges/_course_statistics.html.erb | 45 -----
app/views/colleges/_student_rank.html.erb | 23 ---
app/views/colleges/_teacher_rank.html.erb | 16 --
app/views/colleges/course_statistics.js.erb | 1 -
app/views/colleges/shared/_navbar.html.erb | 21 ---
app/views/colleges/statistics.html.erb | 164 -----------------
app/views/colleges/student_shixun.js.erb | 1 -
app/views/colleges/teachers.js.erb | 1 -
config/routes.rb | 13 --
17 files changed, 1142 deletions(-)
delete mode 100644 app/assets/javascripts/colleges/partner_customers.js
delete mode 100644 app/assets/javascripts/colleges/partner_manager_groups.js
delete mode 100644 app/assets/javascripts/colleges/statistics.js
delete mode 100644 app/assets/stylesheets/colleges/common.scss
delete mode 100644 app/assets/stylesheets/colleges/partner_customers.scss
delete mode 100644 app/assets/stylesheets/colleges/partner_manager_groups.scss
delete mode 100644 app/assets/stylesheets/colleges/statistic.scss
delete mode 100644 app/controllers/colleges_controller.rb
delete mode 100644 app/views/colleges/_course_statistics.html.erb
delete mode 100644 app/views/colleges/_student_rank.html.erb
delete mode 100644 app/views/colleges/_teacher_rank.html.erb
delete mode 100644 app/views/colleges/course_statistics.js.erb
delete mode 100644 app/views/colleges/shared/_navbar.html.erb
delete mode 100644 app/views/colleges/statistics.html.erb
delete mode 100644 app/views/colleges/student_shixun.js.erb
delete mode 100644 app/views/colleges/teachers.js.erb
diff --git a/app/assets/javascripts/colleges/partner_customers.js b/app/assets/javascripts/colleges/partner_customers.js
deleted file mode 100644
index a3c3f1e8d..000000000
--- a/app/assets/javascripts/colleges/partner_customers.js
+++ /dev/null
@@ -1,28 +0,0 @@
-$(document).on('turbolinks:load', function() {
- if ($('body.partners-customers-page').length > 0) {
- var $customerContainer = $('.customer-list-container');
- var partnerId = $customerContainer.find('.customer-list-body').data('id');
-
- $customerContainer.on('change', '.manager-group-select', function(){
- console.log('manager-group-select change', $(this).val());
- var $select = $(this);
- var customerId = $select.data('id');
- var managerGroupId = $select.val();
-
- $.ajax({
- url: '/partners/' + partnerId + '/customer_manager_group.json',
- method: 'POST',
- dataType: 'json',
- data: { customer_id: customerId, manager_group_id: managerGroupId },
- success: function(){
- showSuccessFlash();
- $select.data('last', managerGroupId);
- },
- error: function(res){
- showErrorNotify(res.responseJSON.message);
- $select.val($select.data('last'));
- }
- })
- })
- }
-});
\ No newline at end of file
diff --git a/app/assets/javascripts/colleges/partner_manager_groups.js b/app/assets/javascripts/colleges/partner_manager_groups.js
deleted file mode 100644
index bd9fc32e7..000000000
--- a/app/assets/javascripts/colleges/partner_manager_groups.js
+++ /dev/null
@@ -1,125 +0,0 @@
-$(document).on('turbolinks:load', function() {
- if ($('body.partners-partner-manager-groups-page').length > 0) {
- var $container = $('.manager-group-list-container');
- var partnerId = $container.find('.manager-group-list-body').data('id');
-
- // ------- 新建编辑权限组弹窗 --------
- var $managerGroupModal = $('.modal.partner-save-manager-group-modal');
- var $managerGroupForm = $managerGroupModal.find('form.partner-save-manager-group-form');
- var $managerGroupIdInput = $managerGroupForm.find('input[name="manager_group_id"]');
- var $managerGroupNameInput = $managerGroupForm.find('input[name="manager_group_name"]');
-
- $managerGroupForm.validate({
- errorElement: 'span',
- errorClass: 'danger text-danger',
- rules: {
- manager_group_name: {
- required: true,
- maxlength: 20
- },
- }
- });
-
- $managerGroupModal.on('show.bs.modal', function(event){
- var $link = $(event.relatedTarget);
- var managerGroupId = $link.data('id');
- var managerGroupName = $link.data('name');
-
- if(managerGroupId && managerGroupId !== ''){
- $managerGroupModal.find('.modal-title').html('重命名');
- $managerGroupIdInput.val(managerGroupId);
- $managerGroupNameInput.val(managerGroupName)
- } else {
- $managerGroupModal.find('.modal-title').html('新建');
- $managerGroupIdInput.val('');
- $managerGroupNameInput.val('');
- }
- });
-
- $managerGroupModal.on('hide.bs.modal', function(){
- $managerGroupIdInput.val('');
- $managerGroupNameInput.val('');
- });
-
- $managerGroupModal.on('click', '.submit-btn', function(){
- $managerGroupForm.find('.error').html('');
- var url = $managerGroupForm.data('url');
-
- if ($managerGroupForm.valid()) {
- $.ajax({
- method: 'POST',
- dataType: 'script',
- url: url,
- data: $managerGroupForm.serialize()
- });
- }
- });
-
- // ---------- 添加管理员弹窗 ------------
- var $partnerManagerModal = $('.modal.partner-add-partner-manager-modal');
- var $partnerManagerForm = $partnerManagerModal.find('form.partner-add-partner-manager-form');
- var $managerGroupIdInput = $partnerManagerForm.find('input[name="manager_group_id"]');
- var $userSelect = $partnerManagerForm.find('.partner-manager-select');
-
- $userSelect.select2({
- theme: 'bootstrap4',
- placeholder: '请输入要添加的管理员姓名',
- multiple: true,
- closeOnSelect: false,
- minimumInputLength: 1,
- ajax: {
- delay: 500,
- url: '/api/users_for_partners',
- dataType: 'json',
- data: function(params){
- return { name: params.term, partner_id: partnerId, page: params.page || 1, per_page: 20 };
- },
- processResults: function(data, params){
- params.page = params.page || 1;
-
- return {
- results: data.users,
- pagination: {
- more: (params.page * 20) < data.count
- }
- };
- }
- },
- templateResult: function (item) {
- if(!item.id || item.id === '') return item.text;
- return $("" + item.real_name + " " + item.school_name + ' ' + item.identity + " ");
- },
- templateSelection: function(item){
- if (item.id) {
- }
- return item.real_name || item.text;
- }
- });
-
- $partnerManagerModal.on('show.bs.modal', function(event){
- var $link = $(event.relatedTarget);
- var managerGroupId = $link.data('id');
-
- $managerGroupIdInput.val(managerGroupId);
- $userSelect.select2('val', ' ');
- $partnerManagerModal.find('.error').html('');
- });
-
- $partnerManagerModal.on('click', '.submit-btn', function(){
- $partnerManagerModal.find('.error').html('');
- var managerGroupId = $managerGroupIdInput.val();
-
- var userIds = $userSelect.val();
- if (userIds && userIds.length > 0) {
- $.ajax({
- method: 'POST',
- dataType: 'script',
- url: '/partners/' + partnerId + '/partner_managers',
- data: { user_ids: userIds, manager_group_id: managerGroupId }
- });
- } else {
- $partnerManagerModal.modal('hide');
- }
- });
- }
-});
\ No newline at end of file
diff --git a/app/assets/javascripts/colleges/statistics.js b/app/assets/javascripts/colleges/statistics.js
deleted file mode 100644
index 6e2790df1..000000000
--- a/app/assets/javascripts/colleges/statistics.js
+++ /dev/null
@@ -1,156 +0,0 @@
-$(document).on('turbolinks:load', function() {
- if($('body.colleges-statistics-page').length > 0) {
- var $statisticBody = $('.statistics-body');
- var $statisticBase = $('.statistic-base');
- var schoolId = $statisticBody.data('id');
- var $statisticCourse = $statisticBody.find('.statistic-course')
- var $shixunChart = $statisticBody.find('.shixun-chart');
-
- $.get('/colleges/' + schoolId + '/shixun_time', function(data){
- $statisticBase.find('.shixun-time').html("" + data.shixun_time + " 天");
- });
- $.get('/colleges/' + schoolId + '/shixun_report_count', function(data){
- $statisticBase.find('.shixun-report-count').html("" + data.shixun_report_count + " 个");
- });
-
- $.ajax({ url: '/colleges/' + schoolId + '/course_statistics', method: 'GET', dataType: 'script' });
- $.ajax({ url: '/colleges/' + schoolId + '/teachers', method: 'GET', dataType: 'script' });
-
- var initShixunChart = function(names, data){
- var shixunChart = echarts.init(document.getElementById('shixun-chart'));
- var options = {
- series : [
- {
- name: '访问来源',
- type: 'pie',
- radius: '55%',
- data: data
- }
- ]
- };
-
- shixunChart.setOption(options);
- };
- $.get('/colleges/' + schoolId + '/shixun_chart_data', function(data){
- $statisticBody.find('.shixun-chart-loading').hide();
- if (data.data.length > 0) {
- $shixunChart.css('height', '400px').css('width', '100%');
- initShixunChart(data.names, data.data);
- } else {
- $statisticBody.find('.shixun-chart-empty').show();
- }
- });
-
- $.ajax({ url: '/colleges/' + schoolId + '/student_shixun', method: 'GET', dataType: 'script' });
-
- var initHotEvaluating = function(names, values){
- var Color = ['#962e66', '#623363', '#CCCCCC', '#9A9A9A', '#FF8080', '#FF80C2', '#B980FF', '#80B9FF', '#6FE9FF', '#4DE8B4', '#F8EF63', '#FFB967'];
-
- var option = {
- backgroundColor: '#fff',
- grid: {
- left: '3%',
- right: '4%',
- bottom: '10%',
- containLabel: true
- },
-
- tooltip: {
- show: "true",
- trigger: 'item',
- formatter: '{c0}',
- backgroundColor: 'rgba(0,0,0,0.7)', // 背景
- padding: [8, 10], //内边距
- extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //添加阴影
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- xAxis: {
- type: 'value',
- axisTick: {
- show: false
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: '#CCCCCC'
- }
- },
- splitLine: {
- show: false,
- lineStyle: {
- color: '#CCCCCC'
- }
- },
- axisLabel: {
- textStyle: {
- color: '#656565',
- fontWeight: 'normal',
- fontSize: '12'
- },
- formatter: '{value}'
- }
- },
- yAxis: {
- type: 'category',
- axisLine: {
- lineStyle: {
- color: '#cccccc'
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- splitArea: {
- show: false
- },
- axisLabel: {
- inside: false,
- textStyle: {
- color: '#656565',
- fontWeight: 'normal',
- fontSize: '12'
- }
- },
- data: names
- },
- series: [{
- name: '',
- type: 'bar',
- itemStyle: {
- normal: {
- show: true,
- color: function(params) {
- return Color[params.dataIndex]
- },
- barBorderRadius: 50,
- borderWidth: 0,
- borderColor: '#333'
- }
- },
- barGap: '0%',
- barCategoryGap: '50%',
- data: values
- }
-
- ]
- };
- var myChart = echarts.init(document.getElementById('hot-chart'));
- myChart.setOption(option);
- }
-
- $.get('/colleges/' + schoolId + '/student_hot_evaluations', function(data){
- $statisticBody.find('.hot-chart-loading').hide();
- if (data.names.length > 0) {
- $statisticBody.find('.hot-chart').css('height', '400px').css('width', '100%');
- initHotEvaluating(data.names.reverse(), data.values.reverse());
- } else {
- $statisticBody.find('.hot-chart-empty').show();
- }
- })
- }
-});
\ No newline at end of file
diff --git a/app/assets/stylesheets/colleges/common.scss b/app/assets/stylesheets/colleges/common.scss
deleted file mode 100644
index 6691f747c..000000000
--- a/app/assets/stylesheets/colleges/common.scss
+++ /dev/null
@@ -1,131 +0,0 @@
-.college-body-container {
- padding: 20px;
- flex: 1;
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- overflow-y: scroll;
-
- & > .content {
- flex: 1;
- font-size: 14px;
-
- .box {
- padding: 20px;
- border-radius: 5px;
- background: #fff;
- }
- }
-
- /* 面包屑 */
- .breadcrumb {
- padding-left: 5px;
- font-size: 20px;
- background: unset;
- }
-
- /* 内容表格 */
- table {
- table-layout: fixed;
-
- td {
- vertical-align: middle;
- }
-
- tr {
- &.no-data {
- &:hover {
- color: darkgrey;
- background: unset;
- }
-
- & > td {
- text-align: center;
- height: 300px;
- }
- }
- }
- }
-
- .image-preview-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- .action-container {
- & > .action {
- padding: 0 3px;
- }
-
- .more-action-dropdown {
- .dropdown-item {
- font-size: 14px;
- }
- }
- }
-
- /* 分页 */
- .paginate-container {
- margin-top: 20px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-
- .paginate-total {
- margin-bottom: 10px;
- color: darkgrey;
- }
-
- .pagination {
- margin-bottom: 0px;
- }
- }
-
- /* 搜索表单 */
- .search-form-container {
- display: flex;
- margin-bottom: 20px;
-
- .search-form {
- flex: 1;
-
- * { font-size: 14px; }
-
- select, input {
- margin-right: 10px;
- font-size: 14px;
- }
- }
- }
-
- .global-error {
- color: grey;
- min-height: 300px;
-
- &-code {
- font-size: 80px;
- }
-
- &-text {
- font-size: 24px;
- }
- }
-
- .nav-tabs {
- .nav-link {
- padding: 0.5rem 2rem;
- }
- }
-
- .CodeMirror {
- border: 1px solid #ced4da;
- }
-
- .batch-action-container {
- padding: 10px 20px 0;
- background: #fff;
- }
-}
-
diff --git a/app/assets/stylesheets/colleges/partner_customers.scss b/app/assets/stylesheets/colleges/partner_customers.scss
deleted file mode 100644
index 496c15de9..000000000
--- a/app/assets/stylesheets/colleges/partner_customers.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-.partners-customers-page {
- .customer-list-body {
- min-height: 300px;
- }
-}
\ No newline at end of file
diff --git a/app/assets/stylesheets/colleges/partner_manager_groups.scss b/app/assets/stylesheets/colleges/partner_manager_groups.scss
deleted file mode 100644
index eb264b3d6..000000000
--- a/app/assets/stylesheets/colleges/partner_manager_groups.scss
+++ /dev/null
@@ -1,104 +0,0 @@
-.partners-partner-manager-groups-page {
- .customer-list-form {
- padding: 10px 20px;
- align-items: center;
- }
-
- .manager-group-item {
- margin-bottom: 20px;
-
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- &-left {
- flex: 1;
- }
-
- &-right {
- .action {
- }
- }
- }
- }
-
- .partner-manager {
- &-body {
- display: flex;
- flex-wrap: wrap;
- align-items: flex-start;
- }
-
- &-item {
- padding: 5px 10px;
- display: flex;
- flex-direction: column;
- align-items: center;
- position: relative;
-
- .remove-partner-manager-action {
- display: none;
- position: absolute;
- z-index: 100;
- right: 10px;
- top: 0;
- font-size: 24px;
-
- & > i {
- color: #dc3545;
- }
- }
-
- &:hover {
- .remove-partner-manager-action {
- display: block;
- }
- }
-
- &-avatar {
- cursor: pointer;
- width: 80px;
- height: 80px;
- overflow: hidden;
- border-radius: 50%;
- position: relative;
-
- & > img {
- width: 80px;
- height: 80px;
- }
- }
-
- &.add-partner-manager-item {
- .partner-manager-item-avatar {
- background: #E4E4E4;
-
- &:hover {
- background: #D0D0D0;
- }
-
- &::before {
- content: '';
- position: absolute;
- top: 39px;
- left: 20px;
- width: 40px;
- height: 2px;
- background: #fff;
- }
-
- &::after {
- content: '';
- position: absolute;
- top: 20px;
- left: 39px;
- width: 2px;
- height: 40px;
- background: #fff;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/app/assets/stylesheets/colleges/statistic.scss b/app/assets/stylesheets/colleges/statistic.scss
deleted file mode 100644
index 17540b1f2..000000000
--- a/app/assets/stylesheets/colleges/statistic.scss
+++ /dev/null
@@ -1,137 +0,0 @@
-.colleges-statistics-page {
- .college-body-container {
- padding: 0;
-
- .statistic-header {
- width: 100%;
- height: 240px;
- background-image: url('/images/educoder/statistics.jpg');
- background-size: 100% 100%;
-
- &-container {
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- &-title {
- flex: 1;
- display: flex;
- align-items: center;
- color: #4CACFF;
- font-size: 32px;
- }
-
- &-content {
- width: 100%;
- display: flex;
- justify-content: space-around;
- }
-
- &-item {
- margin-bottom: 22px;
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #fff;
-
- &-label {
- color: #989898;
- }
-
- &-content {
- font-size: 24px;
- }
- }
- }
-
- .statistic-box {
- border: unset;
- box-shadow: 0px 0px 9px rgba(174, 175, 177, 0.2);
- }
-
- .statistic-base {
- &-title {
- padding: 2rem 1.25rem;
- background: #fff;
- border-bottom: unset;
- }
-
- &-table {
- margin: 0;
- padding: 0;
- }
-
- &-item {
- padding: 0;
-
- &-label {
- text-align: center;
- font-size: 16px;
- height: 48px;
- line-height: 48px;
- color: #686868;
- background: #F5F5F5;
- border-top: 1px solid #EBEBEB;
- border-bottom: 1px solid #EBEBEB;
- }
-
- &-content {
- height: 100px;
- font-size: 16px;
- text-align: center;
- line-height: 100px;
-
- span {
- margin-right: 5px;
- font-size: 24px;
- }
- }
- }
- }
-
- .statistic-container {
- padding: 0;
- background: #fff;
- border-radius: 3px;
- box-shadow: 0px 0px 9px rgba(174, 175, 177, 0.2);
-
- .statistic-label {
- padding: 2rem 1.25rem;
- font-size: 1.5rem;
- }
-
- .statistic-table {
- overflow-x: scroll;
- table.course-table { min-width: 1100px; }
- table.teacher-rank-table { min-width: 640px; }
- }
-
- table th {
- background: #F5F5F5;
- border-color: #EBEBEB;
- }
-
- &.statistic-course {
- min-height: 400px;
- }
-
- &.statistic-teacher-rank, &.statistic-student-rank {
- min-height: 500px;
- }
- }
-
- .statistic-chart {
- padding: 0 20px;
- height: 400px;
-
- .shixun-chart-loading, .shixun-chart-empty, .hot-chart-loading, .hot-chart-empty {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100%;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb
deleted file mode 100644
index 4c33ad5e5..000000000
--- a/app/controllers/colleges_controller.rb
+++ /dev/null
@@ -1,171 +0,0 @@
-class CollegesController < ApplicationController
- include PaginateHelper
-
- layout 'college'
-
- before_action :require_login
- before_action :check_college_present!
- before_action :check_manage_permission!
-
- helper_method :current_school, :current_college
-
- def statistics
- # 教师、学生总数
- count_statistic = UserExtension.where(school_id: current_school.id)
- .select('SUM(IF(identity=0, 1, 0)) AS teachers_count, SUM(IF(identity=1, 1, 0)) AS students_count').first
- @teachers_count = count_statistic['teachers_count']
- @students_count = count_statistic['students_count']
-
- # 课堂总数
- @courses_count = Course.where(school_id: current_school.id, is_delete: 0).where.not(id: 1309).count
- # 实训总数
- @shixuns_count = Shixun.visible.joins('left join user_extensions on user_extensions.user_id = shixuns.user_id')
- .where(user_extensions: { school_id: current_school.id }).count
- end
-
- def shixun_time
- time_sum = Game.joins('left join user_extensions on user_extensions.user_id = games.user_id')
- .where(user_extensions: { school_id: current_school.id }).sum(:cost_time)
- shixun_time_sum = (time_sum / (24 * 60 * 60.0)).ceil
-
- render json: { shixun_time: shixun_time_sum }
- end
-
- def shixun_report_count
- shixun_report_count = StudentWork.where(work_status: [1, 2]).where('myshixun_id != 0')
- .joins('left join user_extensions on user_extensions.user_id = student_works.user_id')
- .where(user_extensions: { school_id: current_school.id }).count
- render json: { shixun_report_count: shixun_report_count }
- end
-
- def teachers
- @teachers = User.find_by_sql("SELECT users.id, users.login, users.lastname, users.firstname, users.nickname, IFNULL((SELECT count(shixuns.id) FROM shixuns where shixuns.user_id =users.id group by shixuns.user_id), 0) AS publish_shixun_count,
- (SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.user_id=users.id AND m.role in (1,2,3) and c.school_id = #{current_school.id} AND c.is_delete = 0) as course_count
- FROM `users`, user_extensions ue where ue.school_id=#{current_school.id} and users.id=ue.user_id and ue.identity=0 ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
- # ).order("publish_shixun_count desc, experience desc").limit(10)
- @teachers =
- @teachers.map do |teacher|
- course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{teacher.id} AND c.is_delete = 0 and c.school_id = #{current_school.id}")
- course_count = course_ids.size
- homeworks = HomeworkCommon.where(:homework_type => 4, :course_id => course_ids.map(&:id))
- un_shixun_work_count = homeworks.where("publish_time > '#{Time.now}' or publish_time is null").count
- shixun_work_count = homeworks.size - un_shixun_work_count
- student_count = StudentsForCourse.where(:course_id => course_ids.map(&:id)).count
- myshixun_ids = StudentWork.select("myshixun_id").where("homework_common_id in (#{homeworks.map(&:id).join(',').strip == "" ? -1 : homeworks.map(&:id).join(',')}) and myshixun_id is not null")
- complete_myshixun = Myshixun.select("id").where(:status => 1, :id => myshixun_ids.map(&:myshixun_id)).size
- all_myshixun = Myshixun.select("id").where(:id => myshixun_ids.map(&:myshixun_id)).size
- complete_rate = all_myshixun == 0 ? 0 : ((complete_myshixun * 100) / all_myshixun).try(:round, 2).to_f
- real_name = teacher.show_real_name
- teacher = teacher.attributes.dup.merge({
- real_name: real_name,
- course_count: course_count,
- shixun_work_count: shixun_work_count,
- un_shixun_work_count: un_shixun_work_count,
- student_count: student_count,
- complete_rate: complete_rate
- }).to_json
- JSON.parse(teacher)
- end
- end
-
- def shixun_chart_data
- shixun_ids = HomeworkCommonsShixun.joins(homework_common: :course).where(courses: {school_id: current_school.id, is_delete: 0}).where('courses.id != 1309').pluck('distinct shixun_id')
- shixun_count_map = ShixunTagRepertoire.joins(:tag_repertoire).where(shixun_id: shixun_ids).group('tag_repertoires.name').order('count_shixun_id desc').count(:shixun_id)
-
- names = []
- data = []
- shixun_count_map.each do |name, count|
- break if names.size == 9
-
- names << name
- data << { value: count, name: name }
- end
-
- if shixun_count_map.keys.size > 9
- other_count = shixun_count_map.values[9..-1].reduce(:+)
- names << 'Others'
- data << { name: 'Others', value: other_count }
- end
-
- render json: { names: names, data: data }
- end
-
- # 在线课堂
- def course_statistics
- courses = Course.where(school_id: current_school.id, is_delete: 0).where.not(id: 1309)
-
- courses = courses.left_joins(practice_homeworks: { student_works: { myshixun: :games } })
- .select('courses.id, courses.name, courses.is_end, sum(games.evaluate_count) evaluating_count')
- .group('courses.id').order('is_end asc, evaluating_count desc')
-
- params[:per_page] = 8
- @courses = paginate courses
-
- course_ids = @courses.map(&:id)
- @student_count = StudentsForCourse.where(course_id: course_ids).group(:course_id).count
- @shixun_work_count = HomeworkCommon.where(homework_type: 4, course_id: course_ids).group(:course_id).count
- @attachment_count = Attachment.where(container_id: course_ids, container_type: 'Course').group(:container_id).count
- @message_count = Message.joins(:board).where(boards: { parent_id: 0, course_id: course_ids }).group('boards.course_id').count
- @active_time = CourseActivity.where(course_id: course_ids).group(:course_id).maximum(:created_at)
- @exercise_count = Exercise.where(course_id: course_ids).group(:course_id).count
- @poll_count = Poll.where(course_id: course_ids).group(:course_id).count
- @other_work_count = HomeworkCommon.where(homework_type: [1,3], course_id: course_ids).group(:course_id).count
- end
-
- # 学生实训
- def student_shixun
- @students = User.joins(:user_extension).where(user_extensions: { school_id: current_school.id, identity: 1 }).includes(:user_extension).order('experience desc').limit(10)
-
- student_ids = @students.map(&:id)
- @shixun_count = Myshixun.where(user_id: student_ids).group(:user_id).count
- @study_shixun_count = Myshixun.where(user_id: student_ids, status: 0).group(:user_id).count
- end
-
- def student_hot_evaluations
- games = Game.joins(:myshixun).joins('join shixun_tag_repertoires str on str.shixun_id = myshixuns.shixun_id')
- games = games.joins('join tag_repertoires tr on tr.id = str.tag_repertoire_id')
- games = games.joins("join user_extensions ue on ue.user_id = myshixuns.user_id and ue.school_id = #{current_school.id}")
- evaluate_count_map = games.group('tr.name').reorder('sum_games_evaluate_count desc').limit(10).sum('games.evaluate_count')
-
- render json: { names: evaluate_count_map.keys, values: evaluate_count_map.values }
- end
-
- private
-
- def require_login
- return if User.current.logged?
-
- redirect_to "/login?back_url=#{CGI::escape(request.fullpath)}"
- end
-
- def check_college_present!
- return if current_college.present?
-
- redirect_to '/404'
- end
-
- def check_manage_permission!
- return if can_manage_college?
-
- redirect_to '/403'
- end
-
- def can_manage_college?
- return true if current_user.admin_or_business? # 超级管理员|运营
- return true if current_college.is_a?(Department) && current_college.member?(current_user) # 部门管理员
- return true if current_user.is_teacher? && current_user.school_id == current_school.id # 学校老师
- return true if current_school.customers.exists? && current_user.partner&.partner_customers&.exists?(customer_id: current_school.customer_id)
-
- false
- end
-
- def current_school
- current_college.is_a?(School) ? current_college : current_college.school
- end
-
- def current_college
- @_current_college ||= begin
- Department.find_by(identifier: params[:id]) || School.find_by(id: params[:id])
- end
- end
-end
\ No newline at end of file
diff --git a/app/views/colleges/_course_statistics.html.erb b/app/views/colleges/_course_statistics.html.erb
deleted file mode 100644
index e10739fb2..000000000
--- a/app/views/colleges/_course_statistics.html.erb
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
- 名称
- 管理教师
- 评测次数
- 学生
- 实训作业
- 资源
- 帖子
- 其它任务
- 状态
- 时间
-
-
-
- <% if @courses.present? %>
- <% @courses.each do |course| %>
-
- <%= course.name %>
- <% teacher_names = course.teacher_users.map(&:real_name).join('、') %>
-
-
- <%= teacher_names || '--' %>
-
-
- <%= course.evaluating_count.to_i %>
- <%= @student_count.fetch(course.id, 0) %>
- <%= @shixun_work_count.fetch(course.id, 0) %>
- <%= @attachment_count.fetch(course.id, 0) %>
- <%= @message_count.fetch(course.id, 0) %>
- <%= @exercise_count.fetch(course.id, 0) + @poll_count.fetch(course.id, 0) + @other_work_count.fetch(course.id, 0) %>
- <%= course.is_end ? "已结束" : "正在进行" %>
- <%= @active_time[course.id]&.strftime('%Y-%m-%d %H:%M') %>
-
- <% end %>
- <% else %>
- 暂无数据
- <% end %>
-
-
-
-
- <%= render partial: 'admins/shared/paginate', locals: { objects: @courses } %>
-
\ No newline at end of file
diff --git a/app/views/colleges/_student_rank.html.erb b/app/views/colleges/_student_rank.html.erb
deleted file mode 100644
index b1159587b..000000000
--- a/app/views/colleges/_student_rank.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-<% if @students.present? %>
- <% @students.each_with_index do |student, index| %>
-
-
- <% if index < 3 %>
-
- <% else %>
- <%= index + 1 %>
- <% end %>
-
-
- <%= student.real_name %>
-
- <%= student.student_id %>
- <%= @shixun_count.fetch(student.id, 0) %>
- <%= @study_shixun_count.fetch(student.id, 0) %>
- <%= student.grade %>
- <%= student.experience %>
-
- <% end %>
-<% else %>
-暂无数据
-<% end %>
\ No newline at end of file
diff --git a/app/views/colleges/_teacher_rank.html.erb b/app/views/colleges/_teacher_rank.html.erb
deleted file mode 100644
index 426b9792c..000000000
--- a/app/views/colleges/_teacher_rank.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<% if @teachers.present? %>
- <% @teachers.each_with_index do |teacher, index| %>
-
- <%= index + 1 %>
- <%= teacher['real_name'] %>
- <%= teacher['course_count'] %>
- <%= teacher['shixun_work_count'] %>
- <%= teacher['un_shixun_work_count'] %>
- <%= teacher['student_count'] %>
- <%= teacher['complete_rate'] %>%
- <%= teacher['publish_shixun_count'].to_i %>
-
- <% end %>
-<% else %>
- 暂无数据
-<% end %>
\ No newline at end of file
diff --git a/app/views/colleges/course_statistics.js.erb b/app/views/colleges/course_statistics.js.erb
deleted file mode 100644
index 6ec6cc844..000000000
--- a/app/views/colleges/course_statistics.js.erb
+++ /dev/null
@@ -1 +0,0 @@
-$(".statistic-course .statistic-table").html("<%= j(render 'colleges/course_statistics') %>");
\ No newline at end of file
diff --git a/app/views/colleges/shared/_navbar.html.erb b/app/views/colleges/shared/_navbar.html.erb
deleted file mode 100644
index 7862f864b..000000000
--- a/app/views/colleges/shared/_navbar.html.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/colleges/statistics.html.erb b/app/views/colleges/statistics.html.erb
deleted file mode 100644
index 9f2e8ff7b..000000000
--- a/app/views/colleges/statistics.html.erb
+++ /dev/null
@@ -1,164 +0,0 @@
-
-
-
-
-
-
-
-
教师
-
- <%= @teachers_count %> 人
-
-
-
-
学生
-
- <%= @students_count %> 人
-
-
-
-
课堂
-
- <%= @courses_count %> 个
-
-
-
-
共建实训
-
- <%= @shixuns_count %> 个
-
-
-
-
-
-
-
-
-
-
-
课堂
-
-
-
-
- 名称
- 管理教师
- 评测次数
- 学生
- 实训作业
- 资源
- 帖子
- 其它任务
- 状态
- 时间
-
-
-
- 加载中...
-
-
-
-
-
-
-
-
-
-
教师排名
-
-
-
-
- 排名
- 姓名
- 管理课堂
- 已发布实训作业
- 未发布实训作业
- 学生数
- 完成率
- 发布实训
-
-
-
- 加载中...
-
-
-
-
-
-
-
-
-
-
-
学生排名
-
-
-
-
- 排名
- 姓名
- 学号
- 完成实训
- 在学实训
- 金币
- 经验值
-
-
-
- 加载中...
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/colleges/student_shixun.js.erb b/app/views/colleges/student_shixun.js.erb
deleted file mode 100644
index 73983bf5d..000000000
--- a/app/views/colleges/student_shixun.js.erb
+++ /dev/null
@@ -1 +0,0 @@
-$('.statistic-student-rank table.student-rank-table tbody').html("<%= j(render :partial => 'colleges/student_rank') %>")
\ No newline at end of file
diff --git a/app/views/colleges/teachers.js.erb b/app/views/colleges/teachers.js.erb
deleted file mode 100644
index b13e3ea0c..000000000
--- a/app/views/colleges/teachers.js.erb
+++ /dev/null
@@ -1 +0,0 @@
-$('.statistic-teacher-rank table.teacher-rank-table tbody').html("<%= j(render :partial => 'colleges/teacher_rank') %>")
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 283ee0d24..e082f5987 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1252,19 +1252,6 @@ Rails.application.routes.draw do
end
end
- resources :colleges, only: [] do
- member do
- get :statistics
- get :course_statistics
- get :student_shixun
- get :shixun_time
- get :shixun_report_count
- get :teachers
- get :shixun_chart_data
- get :student_hot_evaluations
- end
- end
-
resources :partners, only: [] do
member do
get :customers