diff --git a/app/controllers/admins/competitions_controller.rb b/app/controllers/admins/competitions_controller.rb
new file mode 100644
index 000000000..3d6bef819
--- /dev/null
+++ b/app/controllers/admins/competitions_controller.rb
@@ -0,0 +1,15 @@
+class Admins::CompetitionsController < Admins::BaseController
+
+ def index
+ params[:sort_by] = params[:sort_by].presence || 'created_on'
+ params[:sort_direction] = params[:sort_direction].presence || 'desc'
+ @competitions = custom_sort Competition.all, params[:sort_by], params[:sort_direction]
+ @params_page = params[:page] || 1
+ @competitions = paginate @competitions
+
+ respond_to do |format|
+ format.js
+ format.html
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index 1081a82ce..2bcc8d8f6 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -2,7 +2,7 @@ class BoardsController < ApplicationController
before_action :require_login, :check_auth
before_action :find_course, only: [:create]
before_action :set_board, except: [:create]
- before_action :teacher_or_admin_allowed
+ before_action :teacher_allowed
def index
@boards = @course.boards.includes(messages: [:last_reply, :author])
diff --git a/app/controllers/course_groups_controller.rb b/app/controllers/course_groups_controller.rb
index 0e16d1bac..bfdb959b4 100644
--- a/app/controllers/course_groups_controller.rb
+++ b/app/controllers/course_groups_controller.rb
@@ -2,7 +2,7 @@ class CourseGroupsController < ApplicationController
before_action :require_login, :check_auth
before_action :set_group, except: [:create]
before_action :find_course, only: [:create]
- before_action :teacher_or_admin_allowed
+ before_action :teacher_allowed
def create
tip_exception("分班名称不能为空") if params[:name].blank?
diff --git a/app/controllers/course_modules_controller.rb b/app/controllers/course_modules_controller.rb
index fccc28f6d..0bef519fd 100644
--- a/app/controllers/course_modules_controller.rb
+++ b/app/controllers/course_modules_controller.rb
@@ -2,7 +2,8 @@ class CourseModulesController < ApplicationController
before_action :require_login, :check_auth
before_action :set_module, except: [:unhidden_modules]
before_action :find_course, only: [:unhidden_modules]
- before_action :teacher_or_admin_allowed
+ before_action :teacher_or_admin_allowed, except: [:add_second_category]
+ before_action :teacher_allowed, only: [:add_second_category]
# 模块置顶
def sticky_module
diff --git a/app/controllers/course_second_categories_controller.rb b/app/controllers/course_second_categories_controller.rb
index e5c3366cd..2de1637f2 100644
--- a/app/controllers/course_second_categories_controller.rb
+++ b/app/controllers/course_second_categories_controller.rb
@@ -1,7 +1,7 @@
class CourseSecondCategoriesController < ApplicationController
before_action :require_login, :check_auth
before_action :set_category
- before_action :teacher_or_admin_allowed
+ before_action :teacher_allowed
# 目录重命名
def rename_category
diff --git a/app/models/competition_mode_setting.rb b/app/models/competition_mode_setting.rb
new file mode 100644
index 000000000..b6bafa7c3
--- /dev/null
+++ b/app/models/competition_mode_setting.rb
@@ -0,0 +1,3 @@
+class CompetitionModeSetting < ApplicationRecord
+ belongs_to :course
+end
diff --git a/app/views/admins/competitions/index.html.erb b/app/views/admins/competitions/index.html.erb
new file mode 100644
index 000000000..8fa238181
--- /dev/null
+++ b/app/views/admins/competitions/index.html.erb
@@ -0,0 +1,7 @@
+<% define_admin_breadcrumbs do %>
+ <% add_admin_breadcrumb('竞赛列表', admins_competitions_path) %>
+<% end %>
+
+
+ <%= render partial: 'admins/shixuns/shared/list', locals: { shixuns: @shixuns } %>
+
diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb
index 145910928..ca6fb2a46 100644
--- a/app/views/admins/shared/_sidebar.html.erb
+++ b/app/views/admins/shared/_sidebar.html.erb
@@ -66,6 +66,8 @@
<% end %>
+ <%= sidebar_item(admins_competitions_path, '竞赛', icon: 'trophy', controller: 'admins-competitions') %>
+
<%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
<%= sidebar_item(admins_carousels_path, '轮播图', icon: 'image', controller: 'admins-carousels') %>
diff --git a/app/views/competitions/competitions/index.json.jbuilder b/app/views/competitions/competitions/index.json.jbuilder
index f0d70f69e..400f17379 100644
--- a/app/views/competitions/competitions/index.json.jbuilder
+++ b/app/views/competitions/competitions/index.json.jbuilder
@@ -20,7 +20,7 @@ json.competitions do
if section
json.current_stage do
- json.name = section.competition_stage.name
+ json.name section.competition_stage.name
json.start_time section.display_start_time
json.end_time section.display_end_time
end
diff --git a/app/views/courses/left_banner.json.jbuilder b/app/views/courses/left_banner.json.jbuilder
index 681145769..f3b80b4f5 100644
--- a/app/views/courses/left_banner.json.jbuilder
+++ b/app/views/courses/left_banner.json.jbuilder
@@ -11,7 +11,7 @@ json.course_modules @course_modules.each do |mod|
case mod.module_type
when "course_group"
# json.none_group_count @course.none_group_count
- json.second_category left_group_info @course
+ # json.second_category left_group_info @course
when "board"
course_board = @course.course_board
if course_board.present?
diff --git a/app/views/courses/mine.json.jbuilder b/app/views/courses/mine.json.jbuilder
index 41368d883..fc6a5becc 100644
--- a/app/views/courses/mine.json.jbuilder
+++ b/app/views/courses/mine.json.jbuilder
@@ -1,5 +1,6 @@
json.partial! "commons/success"
-json.data do
- json.array! @courses, :id, :name, :updated_at, :created_at, :end_date
+json.data @courses do |course|
+ json.(course, :id, :name, :updated_at, :end_date)
+ json.created_at course.created_at.strftime("%Y-%m-%d")
end
diff --git a/app/views/homework_commons/show.json.jbuilder b/app/views/homework_commons/show.json.jbuilder
index 8d5abc8bc..74b60af48 100644
--- a/app/views/homework_commons/show.json.jbuilder
+++ b/app/views/homework_commons/show.json.jbuilder
@@ -4,11 +4,12 @@ json.partial! "homework_btn_check", locals: {identity: @user_course_identity, ho
json.partial! "student_btn_check", locals: {identity: @user_course_identity, homework: @homework, work: @work}
+json.description @homework.description
# 实训作业才有说明
if @homework.homework_type == "practice"
json.explanation @homework.explanation
-else
- json.description @homework.description
+# else
+# json.description @homework.description
end
# 附件
diff --git a/config/routes.rb b/config/routes.rb
index 32725e8e9..f6f8db066 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -980,6 +980,8 @@ Rails.application.routes.draw do
resource :laboratory_setting, only: [:show, :update]
resource :laboratory_user, only: [:create, :destroy]
end
+
+ resources :competitions, only: [:index, :destroy]
end
resources :colleges, only: [] do
diff --git a/db/migrate/20191015013924_add_new_column_to_competitions.rb b/db/migrate/20191015013924_add_new_column_to_competitions.rb
new file mode 100644
index 000000000..616a46059
--- /dev/null
+++ b/db/migrate/20191015013924_add_new_column_to_competitions.rb
@@ -0,0 +1,6 @@
+class AddNewColumnToCompetitions < ActiveRecord::Migration[5.2]
+ def change
+ add_column :competitions, :bonus, :integer, default: 0
+ add_column :competitions, :mode, :integer, default: 0
+ end
+end
diff --git a/db/migrate/20191015015723_create_competition_mode_settings.rb b/db/migrate/20191015015723_create_competition_mode_settings.rb
new file mode 100644
index 000000000..5d170eeab
--- /dev/null
+++ b/db/migrate/20191015015723_create_competition_mode_settings.rb
@@ -0,0 +1,11 @@
+class CreateCompetitionModeSettings < ActiveRecord::Migration[5.2]
+ def change
+ create_table :competition_mode_settings do |t|
+ t.references :course
+ t.datetime :start_time
+ t.datetime :end_time
+
+ t.timestamps
+ end
+ end
+end
diff --git a/public/react/src/modules/courses/members/ChangeRolePop.js b/public/react/src/modules/courses/members/ChangeRolePop.js
index d81c6db46..455e851ee 100644
--- a/public/react/src/modules/courses/members/ChangeRolePop.js
+++ b/public/react/src/modules/courses/members/ChangeRolePop.js
@@ -75,7 +75,7 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces
}
>
- 修改角色
+ 修改角色
)
}
diff --git a/public/react/src/modules/courses/members/CourseGroupChooser.js b/public/react/src/modules/courses/members/CourseGroupChooser.js
index 125f10b51..655754dc4 100644
--- a/public/react/src/modules/courses/members/CourseGroupChooser.js
+++ b/public/react/src/modules/courses/members/CourseGroupChooser.js
@@ -89,7 +89,7 @@ function CourseGroupChooser({ course_groups, isAdminOrCreator = true, item, inde
trigger('groupAdd')}
- >添加分班
+ >新建分班
)
diff --git a/public/react/src/modules/courses/members/CourseGroupList.js b/public/react/src/modules/courses/members/CourseGroupList.js
index 664e0d95a..6c0e915cc 100644
--- a/public/react/src/modules/courses/members/CourseGroupList.js
+++ b/public/react/src/modules/courses/members/CourseGroupList.js
@@ -210,13 +210,13 @@ function CourseGroupList(props) {
onPressEnter={onPressEnter}
>
-
+ {!!none_group_member_count &&
未分班:
{none_group_member_count}个学生
{props.history.push(`/courses/${courseId}/course_groups/0`)}}>查看
-
+
}
{course_groups && !!course_groups.length ?
diff --git a/public/react/src/modules/courses/members/CourseGroupListTable.js b/public/react/src/modules/courses/members/CourseGroupListTable.js
index 1560183f5..656ae67bc 100644
--- a/public/react/src/modules/courses/members/CourseGroupListTable.js
+++ b/public/react/src/modules/courses/members/CourseGroupListTable.js
@@ -134,7 +134,7 @@ function CourseGroupListTable(props) {
{isAdmin && 复制邀请码 }
{isStudent && addToDir(record)} style={''}>加入分班}
- onGoDetail(record)} style={''}>查看
+ onGoDetail(record)} style={''}>查看
}
})
diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js
index 33d434329..a63509c59 100644
--- a/public/react/src/modules/courses/members/studentsList.js
+++ b/public/react/src/modules/courses/members/studentsList.js
@@ -107,7 +107,7 @@ const buildColumns = (that,isParent) => {
}
];
if (course_groups && course_groups.length) {
- columns.push({
+ this.isStudentPage && columns.push({
title: '分班',
dataIndex: 'course_group_name',
key: 'course_group_name',
@@ -148,8 +148,9 @@ const buildColumns = (that,isParent) => {
render: (text, record) => {
return (
- that.onDelete(record)} style={'grey'}>删除学生
+ that.onDelete(record)} style={'grey'}>删除学生
{record.member_roles && record.member_roles.length && {
this.fetchCourseGroups()
+ this.fetchAll()
}
addStudentSuccessListener=(e, data)=>{
@@ -418,12 +423,14 @@ class studentsList extends Component{
invite_code: result.data.invite_code,
isSpin:false
}, () => {
- if (!this.clipboard) {
- const clipboard = new ClipboardJS('.copybtn');
- clipboard.on('success', (e) => {
- this.props.showNotification('复制成功')
- });
- this.clipboard = clipboard
+ if (course_group_id) {
+ if (!this.clipboard) {
+ const clipboard = new ClipboardJS('.copybtn');
+ clipboard.on('success', (e) => {
+ this.props.showNotification('复制成功')
+ });
+ this.clipboard = clipboard
+ }
}
})
}
@@ -588,15 +595,15 @@ class studentsList extends Component{
是否确认删除?
,
onOk: () => {
- // const cid = this.props.match.params.coursesId
const course_group_id = this.props.match.params.course_group_id
+ const courseId = this.props.match.params.coursesId
const url = `/course_groups/${course_group_id}.json`
axios.delete(url)
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('删除成功')
- this.props.history.push(response.data.right_url)
+ this.props.history.push(`/courses/${courseId}/course_groups`)
}
})
.catch(function (error) {
@@ -682,12 +689,14 @@ class studentsList extends Component{
if (this.props.match.path.endsWith('students')) {
} else if (course_group_id) {
- pageType = TYPE_COURSE_GOURP_PARENT
- } else {
pageType = TYPE_COURSE_GOURP_CHILD
+ } else {
+ pageType = TYPE_COURSE_GOURP_PARENT
}
+ // 本页面有2个状态,学生列表、具体分班
const isStudentPage = pageType == TYPE_STUDENTS
this.isStudentPage = isStudentPage
+ const isGroupChildPage = pageType == TYPE_COURSE_GOURP_CHILD
return(
@@ -700,7 +709,12 @@ class studentsList extends Component{
- {course_group_name || '未分班'}
+
+
+ { this.props.history.push(`/courses/${courseId}/course_groups`)}}
+ style={{color: '#212121', verticalAlign: 'initial', marginRight: '14px' }}
+ >
+ {course_group_name || '未分班'}
{isAdmin && invite_code &&
邀请码:
@@ -742,7 +756,7 @@ class studentsList extends Component{
!isStudentPage && !isCourseEnd && isAdmin && this.addDir()}>新建分班 }
{
- !isStudentPage && isStudent && !isParent && course_group_id != 0 && this.addToDir()}>加入分班 }
+ !isStudentPage && isStudent && !isParent && course_group_id != 0 && this.addToDir()}>加入分班 }