Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into yslaliyun1015

dev_auth
杨树林 5 years ago
commit 8a4a93ef9c

@ -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

@ -2,7 +2,7 @@ class BoardsController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :find_course, only: [:create] before_action :find_course, only: [:create]
before_action :set_board, except: [:create] before_action :set_board, except: [:create]
before_action :teacher_or_admin_allowed before_action :teacher_allowed
def index def index
@boards = @course.boards.includes(messages: [:last_reply, :author]) @boards = @course.boards.includes(messages: [:last_reply, :author])

@ -2,7 +2,7 @@ class CourseGroupsController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :set_group, except: [:create] before_action :set_group, except: [:create]
before_action :find_course, only: [:create] before_action :find_course, only: [:create]
before_action :teacher_or_admin_allowed before_action :teacher_allowed
def create def create
tip_exception("分班名称不能为空") if params[:name].blank? tip_exception("分班名称不能为空") if params[:name].blank?

@ -2,7 +2,8 @@ class CourseModulesController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :set_module, except: [:unhidden_modules] before_action :set_module, except: [:unhidden_modules]
before_action :find_course, only: [: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 def sticky_module

@ -1,7 +1,7 @@
class CourseSecondCategoriesController < ApplicationController class CourseSecondCategoriesController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :set_category before_action :set_category
before_action :teacher_or_admin_allowed before_action :teacher_allowed
# 目录重命名 # 目录重命名
def rename_category def rename_category

@ -0,0 +1,3 @@
class CompetitionModeSetting < ApplicationRecord
belongs_to :course
end

@ -0,0 +1,7 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('竞赛列表', admins_competitions_path) %>
<% end %>
<div class="box competitions-list-container">
<%= render partial: 'admins/shixuns/shared/list', locals: { shixuns: @shixuns } %>
</div>

@ -66,6 +66,8 @@
<% end %> <% end %>
</li> </li>
<li><%= sidebar_item(admins_competitions_path, '竞赛', icon: 'trophy', controller: 'admins-competitions') %></li>
<li> <li>
<%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %> <%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
<li><%= sidebar_item(admins_carousels_path, '轮播图', icon: 'image', controller: 'admins-carousels') %></li> <li><%= sidebar_item(admins_carousels_path, '轮播图', icon: 'image', controller: 'admins-carousels') %></li>

@ -20,7 +20,7 @@ json.competitions do
if section if section
json.current_stage do json.current_stage do
json.name = section.competition_stage.name json.name section.competition_stage.name
json.start_time section.display_start_time json.start_time section.display_start_time
json.end_time section.display_end_time json.end_time section.display_end_time
end end

@ -11,7 +11,7 @@ json.course_modules @course_modules.each do |mod|
case mod.module_type case mod.module_type
when "course_group" when "course_group"
# json.none_group_count @course.none_group_count # json.none_group_count @course.none_group_count
json.second_category left_group_info @course # json.second_category left_group_info @course
when "board" when "board"
course_board = @course.course_board course_board = @course.course_board
if course_board.present? if course_board.present?

@ -1,5 +1,6 @@
json.partial! "commons/success" json.partial! "commons/success"
json.data do json.data @courses do |course|
json.array! @courses, :id, :name, :updated_at, :created_at, :end_date json.(course, :id, :name, :updated_at, :end_date)
json.created_at course.created_at.strftime("%Y-%m-%d")
end end

@ -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.partial! "student_btn_check", locals: {identity: @user_course_identity, homework: @homework, work: @work}
json.description @homework.description
# 实训作业才有说明 # 实训作业才有说明
if @homework.homework_type == "practice" if @homework.homework_type == "practice"
json.explanation @homework.explanation json.explanation @homework.explanation
else # else
json.description @homework.description # json.description @homework.description
end end
# 附件 # 附件

@ -980,6 +980,8 @@ Rails.application.routes.draw do
resource :laboratory_setting, only: [:show, :update] resource :laboratory_setting, only: [:show, :update]
resource :laboratory_user, only: [:create, :destroy] resource :laboratory_user, only: [:create, :destroy]
end end
resources :competitions, only: [:index, :destroy]
end end
resources :colleges, only: [] do resources :colleges, only: [] do

@ -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

@ -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

@ -75,7 +75,7 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces
</Checkbox.Group> </Checkbox.Group>
} }
> >
<WordsBtn style={'blue'}>修改角色</WordsBtn> <WordsBtn style={'blue'} style2={props.style}>修改角色</WordsBtn>
</Popconfirm> </Popconfirm>
) )
} }

@ -89,7 +89,7 @@ function CourseGroupChooser({ course_groups, isAdminOrCreator = true, item, inde
<p className="drop_down_btn"> <p className="drop_down_btn">
<a href="javascript:void(0)" className="color-grey-6" <a href="javascript:void(0)" className="color-grey-6"
onClick={() => trigger('groupAdd')} onClick={() => trigger('groupAdd')}
>添加分班</a> >新建分班</a>
</p> </p>
</ul> </ul>
) )

@ -210,13 +210,13 @@ function CourseGroupList(props) {
onPressEnter={onPressEnter} onPressEnter={onPressEnter}
></Titlesearchsection> ></Titlesearchsection>
<div className="mt20 edu-back-white padding20-30 "> {!!none_group_member_count && <div className="mt20 edu-back-white padding20-30 ">
<span>未分班</span> <span>未分班</span>
<span style={{color: '#999999'}}>{none_group_member_count}个学生</span> <span style={{color: '#999999'}}>{none_group_member_count}个学生</span>
<WordsBtn style="blue" className="fr " <WordsBtn style="blue" className="fr "
onClick={() => {props.history.push(`/courses/${courseId}/course_groups/0`)}}>查看</WordsBtn> onClick={() => {props.history.push(`/courses/${courseId}/course_groups/0`)}}>查看</WordsBtn>
</div> </div>}
<Spin size="large" spinning={isSpin}> <Spin size="large" spinning={isSpin}>
{course_groups && !!course_groups.length ? {course_groups && !!course_groups.length ?

@ -134,7 +134,7 @@ function CourseGroupListTable(props) {
{isAdmin && <WordsBtn style2={{ marginRight: '12px' }} data-clipboard-text={record.invite_code} {isAdmin && <WordsBtn style2={{ marginRight: '12px' }} data-clipboard-text={record.invite_code}
className={`copyBtn_${record.id}`} style={''}>复制邀请码</WordsBtn> } className={`copyBtn_${record.id}`} style={''}>复制邀请码</WordsBtn> }
{isStudent && <WordsBtn style2={{ marginRight: '12px' }} onClick={() => addToDir(record)} style={''}>加入分班</WordsBtn>} {isStudent && <WordsBtn style2={{ marginRight: '12px' }} onClick={() => addToDir(record)} style={''}>加入分班</WordsBtn>}
<WordsBtn style2={{ marginRight: '12px' }} onClick={() => onGoDetail(record)} style={''}>查看</WordsBtn> <WordsBtn onClick={() => onGoDetail(record)} style={''}>查看</WordsBtn>
</React.Fragment> </React.Fragment>
} }
}) })

@ -107,7 +107,7 @@ const buildColumns = (that,isParent) => {
} }
]; ];
if (course_groups && course_groups.length) { if (course_groups && course_groups.length) {
columns.push({ this.isStudentPage && columns.push({
title: '分班', title: '分班',
dataIndex: 'course_group_name', dataIndex: 'course_group_name',
key: 'course_group_name', key: 'course_group_name',
@ -148,8 +148,9 @@ const buildColumns = (that,isParent) => {
render: (text, record) => { render: (text, record) => {
return ( return (
<React.Fragment> <React.Fragment>
<WordsBtn style2={{ marginRight: '12px' }} onClick={() => that.onDelete(record)} style={'grey'}>删除学生</WordsBtn> <WordsBtn onClick={() => that.onDelete(record)} style={'grey'}>删除学生</WordsBtn>
{record.member_roles && record.member_roles.length && <ChangeRolePop {record.member_roles && record.member_roles.length && <ChangeRolePop
style={{ marginLeft: '12px' }}
courseId={courseId} courseId={courseId}
record={record} record={record}
member_roles={record.member_roles} member_roles={record.member_roles}
@ -319,6 +320,9 @@ class studentsList extends Component{
isAdmin && on('updateNavSuccess', this.updateNavSuccess) isAdmin && on('updateNavSuccess', this.updateNavSuccess)
} }
componentWillUnmount() { componentWillUnmount() {
if (this.clipboard) {
this.clipboard.destroy()
}
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
if (isAdmin) { if (isAdmin) {
off('addStudentSuccess', this.addStudentSuccessListener) off('addStudentSuccess', this.addStudentSuccessListener)
@ -330,6 +334,7 @@ class studentsList extends Component{
} }
updateNavSuccess = () => { updateNavSuccess = () => {
this.fetchCourseGroups() this.fetchCourseGroups()
this.fetchAll()
} }
addStudentSuccessListener=(e, data)=>{ addStudentSuccessListener=(e, data)=>{
@ -418,12 +423,14 @@ class studentsList extends Component{
invite_code: result.data.invite_code, invite_code: result.data.invite_code,
isSpin:false isSpin:false
}, () => { }, () => {
if (!this.clipboard) { if (course_group_id) {
const clipboard = new ClipboardJS('.copybtn'); if (!this.clipboard) {
clipboard.on('success', (e) => { const clipboard = new ClipboardJS('.copybtn');
this.props.showNotification('复制成功') clipboard.on('success', (e) => {
}); this.props.showNotification('复制成功')
this.clipboard = clipboard });
this.clipboard = clipboard
}
} }
}) })
} }
@ -588,15 +595,15 @@ class studentsList extends Component{
<div>是否确认删除?</div> <div>是否确认删除?</div>
</div>, </div>,
onOk: () => { onOk: () => {
// const cid = this.props.match.params.coursesId
const course_group_id = this.props.match.params.course_group_id 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` const url = `/course_groups/${course_group_id}.json`
axios.delete(url) axios.delete(url)
.then((response) => { .then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.props.showNotification('删除成功') this.props.showNotification('删除成功')
this.props.history.push(response.data.right_url) this.props.history.push(`/courses/${courseId}/course_groups`)
} }
}) })
.catch(function (error) { .catch(function (error) {
@ -682,12 +689,14 @@ class studentsList extends Component{
if (this.props.match.path.endsWith('students')) { if (this.props.match.path.endsWith('students')) {
} else if (course_group_id) { } else if (course_group_id) {
pageType = TYPE_COURSE_GOURP_PARENT
} else {
pageType = TYPE_COURSE_GOURP_CHILD pageType = TYPE_COURSE_GOURP_CHILD
} else {
pageType = TYPE_COURSE_GOURP_PARENT
} }
// 本页面有2个状态学生列表、具体分班
const isStudentPage = pageType == TYPE_STUDENTS const isStudentPage = pageType == TYPE_STUDENTS
this.isStudentPage = isStudentPage this.isStudentPage = isStudentPage
const isGroupChildPage = pageType == TYPE_COURSE_GOURP_CHILD
return( return(
<React.Fragment > <React.Fragment >
@ -700,7 +709,12 @@ class studentsList extends Component{
<Titlesearchsection <Titlesearchsection
title={isParent ? (pageType == TYPE_STUDENTS ? "全部学生" : "学生列表"): title={isParent ? (pageType == TYPE_STUDENTS ? "全部学生" : "学生列表"):
<React.Fragment> <React.Fragment>
<span>{course_group_name || '未分班'}</span> <span>
<Tooltip title="返回">
<i className="icon-zuojiantou iconfont font-14" onClick={() => { this.props.history.push(`/courses/${courseId}/course_groups`)}}
style={{color: '#212121', verticalAlign: 'initial', marginRight: '14px' }}
></i>
</Tooltip>{course_group_name || ''}</span>
{isAdmin && invite_code && <React.Fragment> {isAdmin && invite_code && <React.Fragment>
<span className="color-grey-9 font-16 ml10">邀请码</span> <span className="color-grey-9 font-16 ml10">邀请码</span>
<span className="color-orange font-16"> <span className="color-orange font-16">
@ -742,7 +756,7 @@ class studentsList extends Component{
!isStudentPage && !isCourseEnd && isAdmin && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>新建分班</WordsBtn> } !isStudentPage && !isCourseEnd && isAdmin && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>新建分班</WordsBtn> }
{ {
!isStudentPage && isStudent && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.addToDir()}>加入分班</WordsBtn> } !isStudentPage && isStudent && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="" onClick={()=>this.addToDir()}>加入分班</WordsBtn> }
<style>{` <style>{`
.drop_down_menu li a { .drop_down_menu li a {
padding: 0px; padding: 0px;
@ -797,7 +811,7 @@ class studentsList extends Component{
{ {
total_count > 0 || this.state.isSpin == true ? total_count > 0 || this.state.isSpin == true ?
<div className="mt20 edu-back-white padding20"> <div className="mt20 edu-back-white padding20">
<div className="clearfix stu_head" style={{paddingLeft: '15px'}}> <div className="clearfix stu_head" style={{paddingLeft: '5px'}}>
{isAdmin && !isStudentPage && <Checkbox className="fl" onChange={this.onCheckAll} checked={checkAllValue} >已选 {checkBoxValues.length} </Checkbox>} {isAdmin && !isStudentPage && <Checkbox className="fl" onChange={this.onCheckAll} checked={checkAllValue} >已选 {checkBoxValues.length} </Checkbox>}
<div className="studentList_operation_ul"> <div className="studentList_operation_ul">
{/* {isAdmin && <li className="li_line"><a href="javascript:void(0)" className="color-grey-9" onClick={this.onDelete}>删除</a></li>} */} {/* {isAdmin && <li className="li_line"><a href="javascript:void(0)" className="color-grey-9" onClick={this.onDelete}>删除</a></li>} */}
@ -828,7 +842,7 @@ class studentsList extends Component{
<p className="drop_down_btn"> <p className="drop_down_btn">
<a href="javascript:void(0)" className="color-grey-6" <a href="javascript:void(0)" className="color-grey-6"
onClick={()=>this.addDir()} onClick={()=>this.addDir()}
>添加分班...</a> >新建分班...</a>
</p> </p>
} }

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CompetitionModeSetting, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save