dev_daiao
杨树明 5 years ago
parent ea51baad5e
commit a850f96ef4

@ -30,6 +30,13 @@ if (isDev) {
window.location.search.indexOf('debug=s') != -1 ? 'student' :
window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin'
}
// 超管
// debugType="admin";
// 老师
// debugType="teacher";
// 学生
//debugType="student";
window._debugType = debugType;
export function initAxiosInterceptors(props) {
initOnlineOfflineListener()

@ -1,26 +1,33 @@
import React,{ Component } from "react";
import {Checkbox,Radio, Input,InputNumber,Spin} from "antd";
import {Input,InputNumber,Spin,Statistic} from "antd";
import '../css/members.css'
import '../css/busyWork.css'
import '../poll/pollStyle.css'
import '../css/Courses.css'
import '../css/members.css';
import '../css/busyWork.css';
import '../poll/pollStyle.css';
import '../css/Courses.css';
import moment from 'moment'
import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder'
import Modals from '../../modals/Modals'
import moment from 'moment';
import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder';
import Modals from '../../modals/Modals';
import CoursesListType from '../coursesPublic/CoursesListType';
import Multiple from './question/multiple'
import Single from './question/single'
import FillEmpty from './question/fillEmpty'
import SimpleAnswer from './question/simpleAnswer'
import ShixunAnswer from './question/shixunAnswer'
import Multiple from './question/multiple';
import Single from './question/single';
import FillEmpty from './question/fillEmpty';
import SimpleAnswer from './question/simpleAnswer';
import ShixunAnswer from './question/shixunAnswer';
import update from 'immutability-helper'
import update from 'immutability-helper';
import axios from 'axios';
import './new/common.css'
import './new/common.css';
const { Countdown } = Statistic;
// const deadline = Date.now() + this.state.time*60*60; // Moment is also OK
// console.log(deadline)
const Textarea =Input.TextArea
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
@ -98,32 +105,37 @@ class ExerciseReviewAndAnswer extends Component{
remainTime=(time)=>{
// let { time } = this.state;
let h=moment(parseInt(time)*1000).hour()-8;
let m=moment(parseInt(time)*1000).minutes();
let s=moment(parseInt(time)*1000).seconds();
this.timer = setInterval(() => {
if(time>0){
if(s==0){
if(m > 0){
m--;
}
s=59;
}else{
s--;
}
this.setState({
hour:h,
minute:m,
second:s
})
if(h==0 && m==0 && s==0){
clearInterval(this.timer);
this.autoCommitExercise();
}
}else{
clearInterval(this.timer);
}
},1000)
// let h=moment(parseInt(time)*1000).hour()-8;
// let m=moment(parseInt(time)*1000).minutes();
// let s=moment(parseInt(time)*1000).seconds();
// this.timer = setInterval(() => {
// if(time>0){
// if(s==0){
// if(m > 0){
// m--;
// }
// s=59;
// }else{
// s--;
// }
// this.setState({
// hour:h,
// minute:m,
// second:s
// })
// if(h==0 && m==0 && s==0){
// clearInterval(this.timer);
// this.autoCommitExercise();
// }
// }else{
// clearInterval(this.timer);
// }
// },1000)
}
autosetimes=(time)=>{
this.setState({
time:parseInt(time)
})
}
//自动交卷
autoCommitExercise=()=>{
@ -146,7 +158,8 @@ class ExerciseReviewAndAnswer extends Component{
}
if(result.data.status===-2){
this.remainTime(parseInt(result.data.message))
// this.remainTime(parseInt(result.data.message))
this.autosetimes(result.data.message)
}
}
}).catch((error)=>{
@ -244,7 +257,7 @@ class ExerciseReviewAndAnswer extends Component{
isSpin:false
})
if(result.data.exercise.left_time != null){
this.remainTime(result.data.exercise.left_time);
// this.remainTime(result.data.exercise.left_time);
}
}
}).catch((error)=>{
@ -571,6 +584,14 @@ class ExerciseReviewAndAnswer extends Component{
this.props.history.push(`/courses/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`)
}
deadline=(time)=>{
if(time===null){
}else{
return Date.now() + time * 1000 ;
}
}
render(){
let coursesId=this.props.match.params.coursesId;
let eId=this.props.match.params.Id;
@ -613,6 +634,7 @@ class ExerciseReviewAndAnswer extends Component{
const { current_user } = this.props
// console.log(data&&data.exercise.user_name)
document.title=courseName&&courseName;
return(
<div className="newMain" style={{paddingTop:"0px"}}>
<Spin size="large" spinning={isSpin}>
@ -663,6 +685,7 @@ class ExerciseReviewAndAnswer extends Component{
</p>
<p className="clearfix">
<span className="color-grey-3 font-24 fl lineh-40" >{exercise && exercise.exercise_name}</span>
<span className="fl mt8">
<CoursesListType typelist={[`${statudmap[exercise && exercise.exercise_status]}`]} typesylename={""} />
</span>
@ -671,15 +694,18 @@ class ExerciseReviewAndAnswer extends Component{
<WordsBtn className="fr font-16 lineh-40" style="grey" onClick={this.returnBtn}>返回</WordsBtn>
:
time && time != 0 ?
<div className="fr remainingTime">
<li>{ hour >= 10 ? hour : '0'+hour}</li>
<span>:</span>
<li>{ minute >= 10 ? minute : '0'+minute}</li>
<span>:</span>
<li>{ second >= 10 ? second : '0'+second}</li>
</div>:""
<div className="fr">
<Countdown value={this.deadline(this.state.time)} onFinish={this.autoCommitExercise} />
</div>
:""
}
{/*<div className="fr remainingTime">*/}
{/* <li>{ hour >= 10 ? hour : '0'+hour}</li>*/}
{/* <span>:</span>*/}
{/* <li>{ minute >= 10 ? minute : '0'+minute}</li>*/}
{/* <span>:</span>*/}
{/* <li>{ second >= 10 ? second : '0'+second}</li>*/}
{/*</div>*/}
{
isAdmin && <WordsBtn className="fr font-16 lineh-40 mr30" style="blue" onClick={this.RepeatExercise}>打回重做</WordsBtn>
}

Loading…
Cancel
Save