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

competitions
cxt 5 years ago
commit 48334ee537

@ -92,6 +92,6 @@ class Admins::ShixunSettingsController < Admins::BaseController
end
def setting_params
params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:id,tag_repertoires:[])
params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:page_no, :id,tag_repertoires:[])
end
end

@ -1101,22 +1101,38 @@ class ExercisesController < ApplicationController
def commit_exercise
ActiveRecord::Base.transaction do
begin
if @user_course_identity > Course::ASSISTANT_PROFESSOR #为学生时
objective_score = calculate_student_score(@exercise,current_user)[:total_score]
subjective_score = @answer_committed_user.subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = objective_score + total_score_subjective_score
commit_option = {
can_commit_exercise = false
if (@user_course_identity > Course::ASSISTANT_PROFESSOR) && params[:commit_method].present? #为学生时
if params[:commit_method].to_i == 2 #自动提交时
user_left_time = get_exercise_left_time(@exercise,current_user)
if user_left_time.to_i <= 0
can_commit_exercise = true
end
else
can_commit_exercise = true
end
if can_commit_exercise
objective_score = calculate_student_score(@exercise,current_user)[:total_score]
subjective_score = @answer_committed_user.subjective_score
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = objective_score + total_score_subjective_score
commit_option = {
:status => 1,
:commit_status => 1,
:end_at => Time.now,
:objective_score => objective_score,
:score => total_score,
:subjective_score => subjective_score
}
@answer_committed_user.update_attributes(commit_option)
CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id)
normal_status(0,"试卷提交成功!")
:subjective_score => subjective_score,
:commit_method => @answer_committed_user&.commit_method.to_i > 0 ? @answer_committed_user&.commit_method.to_i : params[:commit_method].to_i
}
@answer_committed_user.update_attributes(commit_option)
CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id)
normal_status(0,"试卷提交成功!")
else
normal_status(-1,"提交失败,请重试!")
end
else
normal_status(-1,"提交失败,请重试!")
end
rescue Exception => e
uid_logger_error(e.message)

@ -19,7 +19,8 @@ class EndExerciseCalculateJob < ApplicationJob
:end_at => Time.now,
:objective_score => objective_score,
:score => total_score,
:subjective_score => user_sub_score
:subjective_score => user_sub_score,
:commit_method => user&.commit_method.to_i > 0 ? user&.commit_method.to_i : 4
}
user.update_attributes(commit_option)
end

@ -1,4 +1,5 @@
class ExerciseUser < ApplicationRecord
# commit_method 0 为默认, 1为学生的手动提交2为倒计时结束后自动提交3为试卷定时截止的自动提交, 4为教师手动的立即截止
belongs_to :user
belongs_to :exercise

@ -1,5 +1,6 @@
class Shixun < ApplicationRecord
include Searchable::Shixun
attr_accessor :page_no #管理员页面 实训配置更新状态时需要接受page_no参数
# status: 0编辑 1申请发布 2正式发布 3关闭 -1软删除
# hide_code 隐藏代码窗口

@ -66,7 +66,8 @@ class ExercisePublishTask
:end_at => Time.now,
:objective_score => s_score,
:score => total_score,
:subjective_score => subjective_score
:subjective_score => subjective_score,
:commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3
}
exercise_user.update_attributes(commit_option)
end
@ -108,7 +109,8 @@ class ExercisePublishTask
:end_at => Time.now,
:objective_score => s_score,
:score => total_score,
:subjective_score => subjective_score
:subjective_score => subjective_score,
:commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3
}
exercise_user.update_attributes(commit_option)
end

@ -8,6 +8,7 @@ json.user_group_name ex_user_info[:user_group_name]
json.student_id ex_user_info[:student_id]
json.commit_status ex_user_info[:commit_status]
json.end_at ex_user_info[:end_at]
json.commit_method exercise_user&.commit_method.to_i
if subjective_type == 1
json.objective_score ex_user_info[:ex_object_score]
json.subjective_score ex_user_info[:ex_subject_score]

@ -9,6 +9,7 @@ json.exercise_answer_user do
json.user_id ex_answerer.id
json.login ex_answerer.login
if exercise_user.present?
json.commit_method exercise_user&.commit_method.to_i
json.start_at exercise_user.start_at
json.score exercise_user.score.present? ? exercise_user.score.round(1).to_s : "0.0"
end

@ -0,0 +1,5 @@
class AddCommitMethodToExerciseUser < ActiveRecord::Migration[5.2]
def change
add_column :exercise_users, :commit_method, :integer, :default => 0
end
end

@ -8,15 +8,21 @@ class WordsBtn extends Component {
}
render() {
let{to, href,targets}=this.props
let{to, href,targets, style2 }=this.props
return(
<React.Fragment>
{
to==undefined&&targets==undefined ?
<a href={href || "javascript:void(0)"} onClick={this.props.onClick} className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</a>:
targets!=undefined? <a href={to} target="_blank" className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</a>
<a href={href || "javascript:void(0)"} onClick={this.props.onClick} className={"btn "+`${map[this.props.style]} ${this.props.className}`}
style={style2}
>{this.props.children}</a>:
targets!=undefined? <a href={to} target="_blank" className={"btn "+`${map[this.props.style]} ${this.props.className}`}
style={style2}
>{this.props.children}</a>
:
<Link to={to} className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</Link>
<Link to={to} className={"btn "+`${map[this.props.style]} ${this.props.className}`}
style={style2}
>{this.props.children}</Link>
}
</React.Fragment>
)

@ -84,4 +84,8 @@
text-overflow:ellipsis;
white-space:nowrap;
cursor: default;
}
.changeRolePop .ant-checkbox-group {
width: 230px !important;
}

@ -129,7 +129,9 @@ class ExerciseReviewAndAnswer extends Component{
autoCommitExercise=()=>{
let eId=this.props.match.params.Id;
let url=`/exercises/${eId}/commit_exercise.json`;
axios.post(url).then((result)=>{
axios.post(url,{
commit_method:2
}).then((result)=>{
if(result){
this.setState({
Modalstype:true,
@ -139,6 +141,7 @@ class ExerciseReviewAndAnswer extends Component{
ModalSave:this.sureCommit,
Loadtype:true
})
this.props.showNotification(`${result.data.message}`);
}
}).catch((error)=>{
console.log(error);
@ -485,7 +488,9 @@ class ExerciseReviewAndAnswer extends Component{
//交卷
let eId=this.props.match.params.Id;
let url=`/exercises/${eId}/commit_exercise.json`;
axios.post(url).then((result)=>{
axios.post(url,{
commit_method:1
}).then((result)=>{
if(result){
this.setState({
Modalstype:false,

@ -0,0 +1,72 @@
import React, { useState, useEffect } from 'react'
import { trigger, WordsBtn } from 'educoder'
import { Input, Checkbox, Popconfirm } from "antd";
import axios from 'axios'
/**
角色数组, CREATOR: 创建者, PROFESSOR: 教师, ASSISTANT_PROFESSOR: 助教, STUDENT: 学生
*/
function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSuccess, showNotification }) {
const [checkBoxRoles, setCheckBoxRoles] = useState(member_roles)
useEffect(() => {
setCheckBoxRoles(member_roles)
}, [member_roles])
function onCheckBoxChange(val) {
console.log(val)
const isTeacher = checkBoxRoles.indexOf('PROFESSOR')
const isAssitant = checkBoxRoles.indexOf('ASSISTANT_PROFESSOR')
const isTeacherNew = val.indexOf('PROFESSOR')
const isAssitantNew = val.indexOf('ASSISTANT_PROFESSOR')
if (isTeacherNew > -1 && isTeacher == -1 && isAssitantNew > -1) {
val.splice(isAssitantNew, 1)
}
if (isAssitantNew > -1 && isAssitant == -1 && isTeacherNew > -1) {
val.splice(isTeacherNew, 1)
}
setCheckBoxRoles(val)
}
function onCancel() {
setCheckBoxRoles(member_roles)
}
const onConfirm = async () => {
if (checkBoxRoles && checkBoxRoles.length == 0) {
showNotification('请至少选择一个角色')
return;
}
const url = `/courses/${courseId}/change_member_role.json`
const response = await axios.post(url, {
roles: checkBoxRoles,
user_id: record.user_id
})
if (response.data.status == 0) {
onChangeRoleSuccess()
}
console.log(response)
}
const isAdmin = checkBoxRoles.indexOf('CREATOR') != -1
const isTeacher = checkBoxRoles.indexOf('PROFESSOR') != -1
const isAssitant = checkBoxRoles.indexOf('ASSISTANT_PROFESSOR') != -1
const isStudent = checkBoxRoles.indexOf('STUDENT') != -1
return (
<Popconfirm
overlayClassName="changeRolePop"
placement="bottom"
icon={null}
onConfirm={onConfirm}
onCancel={onCancel}
title={
<Checkbox.Group style={{ width: '100%' }} onChange={onCheckBoxChange} value={checkBoxRoles}>
{isAdmin && <Checkbox disabled={isAdmin} value="CREATOR">管理员</Checkbox>}
{!isAdmin && <Checkbox value="PROFESSOR">教师</Checkbox>}
<Checkbox disabled={isAdmin} value="ASSISTANT_PROFESSOR">助教</Checkbox>
<Checkbox value="STUDENT">学生</Checkbox>
</Checkbox.Group>
}
>
<WordsBtn style={'blue'}>修改角色</WordsBtn>
</Popconfirm>
)
}
export default ChangeRolePop

@ -0,0 +1,3 @@
.stu_table .ant-table-thead > tr > th, .stu_table .ant-table-tbody > tr > td {
padding: 14px 6px;
}

@ -1,5 +1,5 @@
import React,{ Component } from "react";
import { Input,Checkbox,Table, Pagination, Modal,Menu ,Spin, Tooltip , Divider } from "antd";
import { Input,Checkbox,Table, Pagination, Modal,Menu ,Spin, Tooltip , Divider, Popconfirm } from "antd";
import ClipboardJS from 'clipboard'
import '../css/Courses.css'
import '../css/members.css'
@ -14,6 +14,8 @@ import _ from 'lodash'
import NoneData from "../coursesPublic/NoneData"
import DownloadMessageysl from "../../modals/DownloadMessageysl";
import CreateGroupByImportModal from './modal/CreateGroupByImportModal'
import ChangeRolePop from './ChangeRolePop'
import "./studentsList.css"
const Search =Input.Search;
const TYPE_STUDENTS = 1
@ -22,6 +24,7 @@ const TYPE_COURSE_GOURP_CHILD = 3
const buildColumns = (that,isParent) => {
const { course_groups , sortedInfo } = that.state
let showSorter = isParent==true
const courseId = that.props.match.params.coursesId
const columns=[{
title: '序号',
dataIndex: 'id',
@ -32,19 +35,21 @@ const buildColumns = (that,isParent) => {
render: (id, student, index) => {
return (that.state.page - 1) * 20 + index + 1
}
}, {
title: '用户id',
dataIndex: 'login',
key: 'login',
align:'center',
width:"10%",
className:"color-grey-6",
render: (login, record) => {
return <span className="color-dark overflowHidden1" style={{maxWidth: '160px'}}
title={login && login.length > 10 ? login : ''}
>{login}</span>
}
}, {
},
// {
// title: '用户id',
// dataIndex: 'login',
// key: 'login',
// align:'center',
// width:"10%",
// className:"color-grey-6",
// render: (login, record) => {
// return <span className="color-dark overflowHidden1" style={{maxWidth: '160px'}}
// title={login && login.length > 10 ? login : ''}
// >{login}</span>
// }
// },
{
title: '姓名',
dataIndex: 'name',
key: 'name',
@ -69,14 +74,45 @@ const buildColumns = (that,isParent) => {
return <span className="color-dark overflowHidden1 " title={student_id && student_id.length > 10 ? student_id : ''}
style={{maxWidth: '160px'}} >{student_id}</span>
}
}];
}
, {
title: '手机号',
dataIndex: 'user_phone',
key: 'user_phone',
align:'center',
width:"10%",
className:"color-grey-6",
// sorter: true,
// sortDirections: sortDirections,
// sortOrder: sortedInfo.columnKey === 'user_phone' && sortedInfo.order,
render: (user_phone, record) => {
return <span className="color-dark overflowHidden1 " title={user_phone && user_phone.length > 10 ? user_phone : ''}
style={{maxWidth: '160px'}} >{user_phone}</span>
}
}
, {
title: '邮箱',
dataIndex: 'user_mail',
key: 'user_mail',
align:'center',
width:"10%",
className:"color-grey-6",
// sorter: true,
// sortDirections: sortDirections,
// sortOrder: sortedInfo.columnKey === 'user_mail' && sortedInfo.order,
render: (user_mail, record) => {
return <span className="color-dark overflowHidden1 " title={user_mail && user_mail.length > 10 ? user_mail : ''}
style={{maxWidth: '160px'}} >{user_mail}</span>
}
}
];
if (course_groups && course_groups.length) {
columns.push({
title: '分班',
dataIndex: 'course_group_name',
key: 'course_group_name',
align:'center',
width:"40%",
width:"25%",
className:"color-grey-6",
sorter:showSorter,
sortDirections: sortDirections,
@ -95,14 +131,36 @@ const buildColumns = (that,isParent) => {
const isAdmin = that.props.isAdmin()
if (isAdmin) {
columns.unshift({
title: '',
dataIndex: 'check',
key: 'check',
render: (text, item) => {
return <Checkbox value={item.course_member_id} key={item.course_member_id} ></Checkbox>
},
width:"5%"
})
title: '',
dataIndex: 'check',
key: 'check',
render: (text, item) => {
return <Checkbox value={item.course_member_id} key={item.course_member_id} ></Checkbox>
},
width:"5%"
})
columns.push({
title: '操作',
key: 'action',
width: '20%',
align:'center',
render: (text, record) => {
return (
<React.Fragment>
<WordsBtn style2={{ marginRight: '12px' }} onClick={() => that.onDelete(record)} style={'grey'}>删除学生</WordsBtn>
<ChangeRolePop
courseId={courseId}
record={record}
member_roles={record.member_roles}
onChangeRoleSuccess={that.onChangeRoleSuccess}
showNotification={that.props.showNotification}
></ChangeRolePop>
</React.Fragment>
)
},
})
}
return columns;
@ -242,7 +300,9 @@ class studentsList extends Component{
onChange=()=>{
}
onChangeRoleSuccess = () => {
this.fetchAll()
}
componentDidMount() {
this.setState({
isSpin:true
@ -451,11 +511,13 @@ class studentsList extends Component{
}
}
// 多选
onDelete = () => {
const len = this.state.checkBoxValues.length
if (len == 0) {
this.props.showNotification('请先从列表选择要删除的学生')
return;
onDelete = (record) => {
if (!record) {
const len = this.state.checkBoxValues.length
if (len == 0) {
this.props.showNotification('请先从列表选择要删除的学生')
return;
}
}
this.props.confirm({
@ -465,7 +527,7 @@ class studentsList extends Component{
let id = this.props.match.params.coursesId
let url=`/courses/${id}/delete_from_course.json`;
axios.post((url), {
students: this.state.checkBoxValues.map(item => {return {course_member_id: item} }),
students: [{course_member_id: record.course_member_id}] // this.state.checkBoxValues.map(item => {return {course_member_id: item} }),
}).then((result)=>{
if (result.data.status == 0) {
this.props.showNotification('删除成功')
@ -701,7 +763,7 @@ class studentsList extends Component{
<div className="clearfix stu_head" style={{paddingLeft: '15px'}}>
{isAdmin && <Checkbox className="fl" onChange={this.onCheckAll} checked={checkAllValue} >已选 {checkBoxValues.length} </Checkbox>}
<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>} */}
{isAdmin && <li className="drop_down">
移动到...<i className="iconfont icon-xiajiantou font-12 ml2"></i>
<ul className="drop_down_menu" style={{"right":"0px","left":"unset", width: '200px', maxHeight: '324px', overflowY: 'auto'}}>
@ -752,7 +814,7 @@ class studentsList extends Component{
</div>
<Spin size="large" spinning={this.state.isSpin}>
<div className="clearfix stu_table">
{!this.state.isSpin && <Checkbox.Group style={{ width: '100%' }} onChange={this.onCheckBoxChange} value={checkBoxValues}>
{students && students.length && <Checkbox.Group style={{ width: '100%' }} onChange={this.onCheckBoxChange} value={checkBoxValues}>
<Table columns={buildColumns(this,isParent)} dataSource={students} onChange={this.onTableChange} pagination={false}></Table>
</Checkbox.Group> }
</div>

@ -1,5 +1,5 @@
import React,{ Component } from "react";
import { Input,Checkbox,Table, Divider, Tooltip,Spin, Menu } from "antd";
import { Input,Checkbox,Table, Divider, Tooltip,Spin, Menu, Popconfirm } from "antd";
import CourseLayoutcomponent from '../common/CourseLayoutComponent'
import NoneData from "../coursesPublic/NoneData"
@ -24,6 +24,7 @@ import AddAdminModal from './modal/AddAdminModal'
import CourseGroupChooserModal from './modal/CourseGroupChooserModal'
import { ROLE_TEACHER_NUM, ROLE_ASSISTANT_NUM } from './common'
import CourseGroupChooser from './CourseGroupChooser'
import ChangeRolePop from './ChangeRolePop'
const Search = Input.Search;
const ROLE_ADMIN = "管理员"
@ -38,6 +39,8 @@ function buildColumns(that) {
const isAdminOrTeacher = that.props.isAdminOrTeacher()
const { course_groups, filterKey } = that.state
const showSorter = filterKey == '1'
const courseId = that.props.match.params.coursesId
const columns = [{
title: '序号',
dataIndex: 'name',
@ -117,7 +120,7 @@ function buildColumns(that) {
const hasGraduationModule = that.hasGraduationModule()
if (hasGraduationModule && showSorter) {
columns.push({
title: '答辩组',
title: '所在答辩组',
// width: 90,
sorter: showSorter,
sortDirections: sortDirections,
@ -141,6 +144,9 @@ function buildColumns(that) {
width: 150,
align:'center',
render: (text, record) => {
const isAdmin = record.role == ROLE_ADMIN
const isTeacher = record.role == ROLE_TEACHER
const isAssitant = record.role == ROLE_TEACHER_ASSISTANT
if (record.application_id) {
return (
<span>
@ -149,16 +155,43 @@ function buildColumns(that) {
<a onClick={() => that.onAgree(record)} style={{color: '#4CACFF'}}>同意</a>
</span> )
} else {
return (
<span>
{record.role != ROLE_ADMIN && <WordsBtn onClick={() => that.onDelete(record)} style={'grey'}>删除</WordsBtn>}
{(record.role == ROLE_TEACHER || record.role == ROLE_TEACHER_ASSISTANT || isAdminOrCreator) && record.role != ROLE_ADMIN
&& <Divider type="vertical" />}
{ record.role == ROLE_TEACHER ? <a style={{color: '#4CACFF'}} onClick={() => that.changeToAssistant(record)}>变更为助教</a> : '' }
{ record.role == ROLE_TEACHER_ASSISTANT ? <a style={{color: '#4CACFF'}} onClick={() => that.changeToTeacher(record)}>变更为教师</a> : '' }
{ record.role == ROLE_ADMIN && isAdminOrCreator ? <a style={{color: '#4CACFF', marginLeft: '44px'}} onClick={() => that.showChangeAdminModal(record)}>更换管理员</a> : '' }
<React.Fragment>
<WordsBtn style2={{ marginRight: '12px' }} onClick={() => that.onDelete(record)} style={'grey'}>删除</WordsBtn>
<ChangeRolePop
courseId={courseId}
record={record}
member_roles={record.member_roles}
onChangeRoleSuccess={that.onChangeRoleSuccess}
showNotification={that.props.showNotification}
></ChangeRolePop>
{/* <Popconfirm
placement="bottom"
icon={null}
title={
<React.Fragment>
<Checkbox disable={isAdmin}>管理员</Checkbox>
<Checkbox disable={isAdmin}>助教</Checkbox>
<Checkbox >学生</Checkbox>
</React.Fragment>
}
>
<WordsBtn style={'blue'}>修改角色</WordsBtn>
</Popconfirm> */}
</React.Fragment>
// <span>
// {record.role != ROLE_ADMIN && <WordsBtn onClick={() => that.onDelete(record)} style={'grey'}>删除</WordsBtn>}
// {(record.role == ROLE_TEACHER || record.role == ROLE_TEACHER_ASSISTANT || isAdminOrCreator) && record.role != ROLE_ADMIN
// && <Divider type="vertical" />}
// { record.role == ROLE_TEACHER ? <a style={{color: '#4CACFF'}} onClick={() => that.changeToAssistant(record)}>变更为助教</a> : '' }
// { record.role == ROLE_TEACHER_ASSISTANT ? <a style={{color: '#4CACFF'}} onClick={() => that.changeToTeacher(record)}>变更为教师</a> : '' }
// { record.role == ROLE_ADMIN && isAdminOrCreator ? <a style={{color: '#4CACFF', marginLeft: '44px'}} onClick={() => that.showChangeAdminModal(record)}>更换管理员</a> : '' }
</span> )
// </span>
)
}
},
@ -344,6 +377,9 @@ class studentsList extends Component{
console.log(error);
});
}
onChangeRoleSuccess = () => {
this.fetchAll()
}
fetchAll = async (argPage) => {
this.setState({
isSpin:true

@ -354,8 +354,8 @@ class ShixunhomeWorkItem extends Component{
<span className="mr50 df">
{/* <a href="/users/innov" className="panel-name-small hide fl mr15 mr30 color-grey3">{discussMessage.author.name}</a> */}
{ discussMessage.author && <span className="mr15 color-grey-3">{discussMessage.author}</span> }
{discussMessage.commit_count===undefined?"":<span className="mr15 color-grey9">{discussMessage.commit_count} </span>}
{discussMessage.uncommit_count===undefined?"":<span className="mr15 color-grey9">{discussMessage.uncommit_count} </span>}
{discussMessage.commit_count===undefined?"":<span className="mr15 color-grey9">{discussMessage.commit_count} 开始做题</span>}
{discussMessage.uncommit_count===undefined?"":<span className="mr15 color-grey9">{discussMessage.uncommit_count} 开始做题</span>}
{/*<span className="mr15 color-grey9">{discussMessage.replies_count} 3 未评</span>*/}
{
@ -381,7 +381,7 @@ class ShixunhomeWorkItem extends Component{
{
discussMessage && discussMessage.upper_category_name &&
<ConditionToolTip title={discussMessage.upper_category_name} condition={ discussMessage.upper_category_name.length > 22 }>
{ <span className="mr15 color-grey9 task-hide" style={discussMessage.time_status===1||discussMessage.time_status===2||discussMessage.time_status===3||discussMessage.time_status===4?{"maxWidth":"200px"}:{"maxWidth":"272px"}} title={discussMessage.upper_category_name}>{discussMessage.upper_category_name}</span>}
{ <span className="mr15 color-grey9 task-hide" style={discussMessage.time_status===1||discussMessage.time_status===2||discussMessage.time_status===3||discussMessage.time_status===4?{"maxWidth":"111px"}:{"maxWidth":"272px"}} title={discussMessage.upper_category_name}>{discussMessage.upper_category_name}</span>}
</ConditionToolTip>
}

Loading…
Cancel
Save