dev_aliyun2
harry 5 years ago
parent 5365ef8103
commit 4130592750

@ -1,5 +1,6 @@
import React, { Component } from "react";
import { Input, InputNumber, Spin, Statistic } from "antd"; import React,{ Component } from "react";
import {Input,InputNumber,Spin,Statistic} from "antd";
import '../css/members.css'; import '../css/members.css';
import '../css/busyWork.css'; import '../css/busyWork.css';
@ -7,7 +8,7 @@ import '../poll/pollStyle.css';
import '../css/Courses.css'; import '../css/Courses.css';
import moment from 'moment'; import moment from 'moment';
import { WordsBtn, markdownToHTML, ActionBtn, getImageUrl, MarkdownToHtml } from 'educoder'; import { WordsBtn,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder';
import Modals from '../../modals/Modals'; import Modals from '../../modals/Modals';
import CoursesListType from '../coursesPublic/CoursesListType'; import CoursesListType from '../coursesPublic/CoursesListType';
@ -28,81 +29,82 @@ const { Countdown } = Statistic;
// console.log(deadline) // console.log(deadline)
const Textarea = Input.TextArea const Textarea =Input.TextArea
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
] ]
const $ = window.$; const $ = window.$;
const statudmap = { 1: "未发布", 2: "已发布", 3: "已截止" } const statudmap={1:"未发布",2:"已发布",3:"已截止"}
const type = ["单选题", "多选题", "判断题", "填空题", "简答题", "实训题"] const type=["单选题","多选题","判断题","填空题","简答题","实训题"]
const format = "YYYY-MM-DD HH:mm" const format="YYYY-MM-DD HH:mm"
class ExerciseReviewAndAnswer extends Component { class ExerciseReviewAndAnswer extends Component{
constructor(props) { constructor(props){
super(props); super(props);
this.state = { this.state={
data: undefined, data:undefined,
questionPanelFixed: false, questionPanelFixed:false,
e_ReviewInfo: undefined, e_ReviewInfo:undefined,
e_AnswerInfo: undefined, e_AnswerInfo:undefined,
courseName: undefined, courseName:undefined,
exercise: undefined, exercise:undefined,
question_types: undefined, question_types:undefined,
exercise_questions: undefined, exercise_questions:undefined,
time: undefined, time:undefined,
hour: 0, hour:0,
minute: 0, minute:0,
second: 0, second:0,
Modalstype: false, Modalstype:false,
Modalstopval: undefined, Modalstopval:undefined,
modalsBottomval: undefined, modalsBottomval:undefined,
ModalCancel: undefined, ModalCancel:undefined,
ModalSave: undefined, ModalSave:undefined,
Loadtype: undefined, Loadtype:undefined,
// 问卷是否可以被编辑(老师/试卷已截止/问卷已提交为1 // 问卷是否可以被编辑(老师/试卷已截止/问卷已提交为1
user_exercise_status: undefined, user_exercise_status:undefined,
// 开始答题时间 // 开始答题时间
exercise_start_at: undefined, exercise_start_at:undefined,
//老师身份 //老师身份
exercise_scores: undefined, exercise_scores:undefined,
exercise_answer_user: undefined, exercise_answer_user:undefined,
//学生身份 //学生身份
question_status: undefined, question_status:undefined,
score: undefined, score:undefined,
setScoreReason: undefined, setScoreReason:undefined,
setTip: "", setTip:"",
Id: undefined, Id:undefined,
// 试卷总分 // 试卷总分
exerciseTotalScore: undefined, exerciseTotalScore:undefined,
// 加载效果 // 加载效果
isSpin: false, isSpin:false,
// 调分数组 // 调分数组
ajustSore: undefined ajustSore:undefined
} }
} }
componentDidUpdate(prevProps) { componentDidUpdate (prevProps) {
// 需要等get_user_info执行完才能getInfo
if (!prevProps.coursedata.name && this.props.coursedata.name) { if (!prevProps.coursedata.name && this.props.coursedata.name) {
this.getInfo() this.getInfo()
} }
} }
componentDidMount() { componentDidMount(){
if (this.props.coursedata.name) { if(this.props.coursedata.name){
this.getInfo(); this.getInfo();
} }
//window.addEventListener('scroll', this.handleScroll); //window.addEventListener('scroll', this.handleScroll);
} }
remainTime = (time) => { remainTime=(time)=>{
// let { time } = this.state; // let { time } = this.state;
// let h=moment(parseInt(time)*1000).hour()-8; // let h=moment(parseInt(time)*1000).hour()-8;
// let m=moment(parseInt(time)*1000).minutes(); // let m=moment(parseInt(time)*1000).minutes();
@ -133,100 +135,98 @@ class ExerciseReviewAndAnswer extends Component {
} }
//自动交卷 //自动交卷
autoCommitExercise = () => { autoCommitExercise=()=>{
let eId = this.props.match.params.Id; let eId=this.props.match.params.Id;
let url = `/exercises/${eId}/commit_exercise.json`; let url=`/exercises/${eId}/commit_exercise.json`;
axios.post(url, { axios.post(url,{
commit_method: 2 commit_method:2
}).then((result) => { }).then((result)=>{
if (result) { if(result){
if (result.data.status === 0) { if(result.data.status===0){
this.setState({ this.setState({
Modalstype: true, Modalstype:true,
Modalstopval: '答题结束了,系统已自动提交试卷', Modalstopval:'答题结束了,系统已自动提交试卷',
modalsBottomval: "不能再修改答题", modalsBottomval:"不能再修改答题",
ModalCancel: undefined, ModalCancel:undefined,
ModalSave: this.sureCommit, ModalSave:this.sureCommit,
Loadtype: true, Loadtype:true,
time: null, time:null,
}) })
this.props.showNotification(`${result.data.message}`); this.props.showNotification(`${result.data.message}`);
} }
if (result.data.status === -2) { if(result.data.status===-2){
// this.remainTime(parseInt(result.data.message)) // this.remainTime(parseInt(result.data.message))
this.setState({ this.setState({
time: parseInt(result.data.mess) time:parseInt(result.data.mess)
}) })
this.deadline(parseInt(result.data.message)) this.deadline(parseInt(result.data.message))
} }
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} }
sureCommit = () => { sureCommit=()=>{
let coursesId = this.props.match.params.coursesId; let coursesId = this.props.match.params.coursesId;
let eId = this.props.match.params.Id; let eId = this.props.match.params.Id;
this.props.history.push(`/classrooms/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`); this.props.history.push(`/classrooms/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`);
} }
// 滚动定位 // 滚动定位
handleScroll = () => { handleScroll=()=>{
if (parseInt(window.scrollY) > 550) { if(parseInt(window.scrollY)>550){
this.setState({ this.setState({
questionPanelFixed: true questionPanelFixed:true
}) })
} else { }else{
this.setState({ this.setState({
questionPanelFixed: false questionPanelFixed:false
}) })
} }
} }
getInfo = () => { getInfo=()=>{
this.setState({ this.setState({
courseName: this.props.current_user.course_name, courseName:this.props.current_user.course_name,
isSpin: true isSpin:true
}) })
let eId = this.props.match.params.Id; let eId=this.props.match.params.Id;
let user_id = this.props.match.params.userId; let user_id=this.props.match.params.userId;
let isAdmin = this.props.isAdmin(); let isAdmin=this.props.isAdmin();
if (isAdmin) { if(isAdmin){
let url = `/exercises/${eId}/review_exercise.json` let url=`/exercises/${eId}/review_exercise.json`
axios.get((url), { axios.get((url),{params:{
params: { login:user_id
login: user_id }}).then((result)=>{
} if(result){
}).then((result) => {
if (result) {
this.setState({ this.setState({
data: result.data, data:result.data,
e_ReviewInfo: result.data, e_ReviewInfo:result.data,
exercise: result.data.exercise, exercise:result.data.exercise,
exercise_types: result.data.exercise_scores.exercise_types, exercise_types:result.data.exercise_scores.exercise_types,
exercise_scores: result.data.exercise_scores, exercise_scores:result.data.exercise_scores,
exercise_start_at: result.data.exercise_answer_user.start_at, exercise_start_at:result.data.exercise_answer_user.start_at,
exercise_answer_user: result.data.exercise_answer_user, exercise_answer_user:result.data.exercise_answer_user,
exercise_questions: result.data.exercise_questions, exercise_questions:result.data.exercise_questions,
user_exercise_status: 1, user_exercise_status:1,
Id: result.data.exercise_answer_user.user_id, Id:result.data.exercise_answer_user.user_id,
exerciseTotalScore: result.data.exercise_answer_user.score, exerciseTotalScore:result.data.exercise_answer_user.score,
isSpin: false, isSpin:false,
}) })
// 先将未批的简答题放入到调分数组中 // 先将未批的简答题放入到调分数组中
let ajustSore = []; let ajustSore = [];
result.data && result.data.exercise_questions.length > 0 && result.data.exercise_questions.map((item, key) => { result.data && result.data.exercise_questions.length>0 && result.data.exercise_questions.map((item,key)=>{
if (item.question_type == 4 && item.answer_status == 0) { if( item.question_type == 4 && item.answer_status == 0 ){
ajustSore.push({ ajustSore.push({
inputSore: 0, inputSore:0,
desc: undefined, desc:undefined,
id: item.question_id, id:item.question_id,
position: item.q_position, position:item.q_position,
setTip: "" setTip:""
}) })
} }
}) })
@ -234,53 +234,51 @@ class ExerciseReviewAndAnswer extends Component {
ajustSore ajustSore
}) })
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} else { }else{
let url = `/exercises/${eId}/start_answer.json` let url=`/exercises/${eId}/start_answer.json`
axios.get((url), { axios.get((url),{params:{
params: { login:user_id
login: user_id }}).then((result)=>{
} if(result.status==200){
}).then((result) => {
if (result.status == 200) {
this.setState({ this.setState({
data: result.data, data:result.data,
e_AnswerInfo: result.data, e_AnswerInfo:result.data,
exercise: result.data.exercise, exercise:result.data.exercise,
exercise_types: result.data.exercise_types, exercise_types:result.data.exercise_types,
question_status: result.data.question_status, question_status:result.data.question_status,
exercise_start_at: result.data.exercise.exercise_start_at, exercise_start_at:result.data.exercise.exercise_start_at,
exercise_scores: result.data.exercise_scores, exercise_scores:result.data.exercise_scores,
exercise_questions: result.data.exercise_questions, exercise_questions:result.data.exercise_questions,
user_exercise_status: result.data.exercise.user_exercise_status, user_exercise_status:result.data.exercise.user_exercise_status,
time: result.data.exercise.left_time, time:result.data.exercise.left_time,
exerciseTotalScore: result.data.user_score, exerciseTotalScore:result.data.user_score,
isSpin: false isSpin:false
}) })
if (result.data.exercise.left_time != null) { if(result.data.exercise.left_time != null){
// this.remainTime(result.data.exercise.left_time); // this.remainTime(result.data.exercise.left_time);
this.deadline(result.data.exercise.left_time) this.deadline(result.data.exercise.left_time)
} }
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} }
} }
scrollToAnchor = (index) => { scrollToAnchor=(index)=>{
let name = "Anchor_" + index; let name="Anchor_"+index;
// console.log($("#Anchor_"+index).scrollTop()); // console.log($("#Anchor_"+index).scrollTop());
if (index) { if (index) {
// let anchorElement = document.getElementById(name); // let anchorElement = document.getElementById(name);
// if(anchorElement) { anchorElement.scrollIntoView(); } // if(anchorElement) { anchorElement.scrollIntoView(); }
$("html").animate({ scrollTop: $("#Anchor_" + index).offset().top - 150 }) $("html").animate({ scrollTop: $("#Anchor_"+index).offset().top - 150 })
} }
} }
//答题后更改题目列表得状态 //答题后更改题目列表得状态
changeQuestionStatus = (No, flag) => { changeQuestionStatus=(No,flag)=>{
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
question_status : update(prevState.question_status, {[No]: { ques_status: {$set: flag} }}) question_status : update(prevState.question_status, {[No]: { ques_status: {$set: flag} }})
@ -288,7 +286,7 @@ class ExerciseReviewAndAnswer extends Component {
) )
} }
// 调分 // 调分
showSetScore = (key, flag, position, type, id) => { showSetScore=(key,flag,position,type,id)=>{
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
exercise_questions : update(prevState.exercise_questions, {[key]: { setScore: {$set: flag == undefined || flag==false ? true : false}}}) exercise_questions : update(prevState.exercise_questions, {[key]: { setScore: {$set: flag == undefined || flag==false ? true : false}}})
@ -299,13 +297,13 @@ class ExerciseReviewAndAnswer extends Component {
if(id){ if(id){
let { ajustSore } = this.state; let { ajustSore } = this.state;
let obj = ajustSore.filter(obj => obj.id === id).length > 0; let obj = ajustSore.filter(obj => obj.id === id).length > 0;
if (!obj) { if(!obj){
ajustSore.push({ ajustSore.push({
id, id,
inputSore: 0, inputSore:0,
desc: undefined, desc:undefined,
position: position, position:position,
setTip: "" setTip:""
}) })
} }
} }
@ -317,11 +315,11 @@ class ExerciseReviewAndAnswer extends Component {
// }) // })
} }
inputScore = (value, id) => { inputScore=(value,id)=>{
let { ajustSore } = this.state; let { ajustSore } = this.state;
var index = ajustSore.map(function (item) { return item.id; }).indexOf(id); var index = ajustSore.map(function (item) { return item.id; }).indexOf(id);
let reg = /^[0-9]+.?[0-9]*$/; let reg = /^[0-9]+.?[0-9]*$/;
if (reg.test(value) == false) { if(reg.test(value)==false){
// this.setState({ // this.setState({
// setTip:"请输入数字" // setTip:"请输入数字"
// }) // })
@ -331,7 +329,7 @@ class ExerciseReviewAndAnswer extends Component {
}) })
) )
return; return;
} else { }else{
// this.setState({ // this.setState({
// setTip:"", // setTip:"",
// score:value // score:value
@ -343,7 +341,7 @@ class ExerciseReviewAndAnswer extends Component {
) )
} }
} }
changeScoreReasons = (e, id) => { changeScoreReasons=(e,id)=>{
// console.log(e.target.value); // console.log(e.target.value);
// this.setState({ // this.setState({
// setScoreReason:e.target.value // setScoreReason:e.target.value
@ -357,16 +355,16 @@ class ExerciseReviewAndAnswer extends Component {
}) })
) )
} }
//确认调分 //确认调分
setAction = (key, q_id, maxScore, oldScore) => { setAction=(key,q_id,maxScore,oldScore)=>{
let { ajustSore } = this.state; let {ajustSore}=this.state;
let list = ajustSore.filter(obj => obj.id == q_id); let list = ajustSore.filter(obj => obj.id == q_id);
let index = ajustSore.map(function (item) { return item.id; }).indexOf(q_id); let index = ajustSore.map(function (item) { return item.id; }).indexOf(q_id);
let score = list[0].inputSore; let score = list[0].inputSore;
let setScoreReason = list[0].desc; let setScoreReason = list[0].desc;
let { setTip } = this.state; let{ setTip }=this.state;
if (!score && score != 0) { if(!score && score != 0){
// this.setState({ // this.setState({
// setTip:"请输入分数" // setTip:"请输入分数"
// }) // })
@ -377,7 +375,7 @@ class ExerciseReviewAndAnswer extends Component {
) )
return; return;
} }
if (score < 0) { if(score < 0){
// this.setState({ // this.setState({
// setTip:"分数必须大于或者等于0" // setTip:"分数必须大于或者等于0"
// }) // })
@ -388,7 +386,7 @@ class ExerciseReviewAndAnswer extends Component {
) )
return; return;
} }
if (score > maxScore) { if(score > maxScore){
// this.setState({ // this.setState({
// setTip:"分数不能大于当前题目的分数" // setTip:"分数不能大于当前题目的分数"
// }) // })
@ -399,14 +397,14 @@ class ExerciseReviewAndAnswer extends Component {
) )
return; return;
} }
if (setTip == "") { if(setTip==""){
let url = `/exercise_questions/${q_id}/adjust_score.json` let url=`/exercise_questions/${q_id}/adjust_score.json`
axios.post((url), { axios.post((url),{
score: score, score:score,
user_id: this.state.Id, user_id:this.state.Id,
comment: setScoreReason comment:setScoreReason
}).then((result) => { }).then((result)=>{
if (result.status == 200) { if(result.status==200){
this.props.showNotification('调分成功'); this.props.showNotification('调分成功');
this.getInfo(); this.getInfo();
// let statusScore = score==0 ? 0 : score > 0 && score < maxScore ? 2 : 1; // let statusScore = score==0 ? 0 : score > 0 && score < maxScore ? 2 : 1;
@ -429,7 +427,7 @@ class ExerciseReviewAndAnswer extends Component {
// }) // })
// this.showSetScore(key,true); // this.showSetScore(key,true);
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} }
@ -437,7 +435,7 @@ class ExerciseReviewAndAnswer extends Component {
} }
// 选择题,切换答案 // 选择题,切换答案
changeOption = (index, ids) => { changeOption = (index,ids) =>{
//console.log(index+" "+ids); //console.log(index+" "+ids);
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
@ -447,7 +445,7 @@ class ExerciseReviewAndAnswer extends Component {
} }
//简答题 显示和隐藏答案 //简答题 显示和隐藏答案
changeA_flag = (index, status) => { changeA_flag=(index,status)=>{
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
exercise_questions : update(prevState.exercise_questions, {[index]: { a_flag: {$set: status} }}) exercise_questions : update(prevState.exercise_questions, {[index]: { a_flag: {$set: status} }})
@ -456,127 +454,127 @@ class ExerciseReviewAndAnswer extends Component {
} }
//交卷和保存前判断是否有题未答 //交卷和保存前判断是否有题未答
checkExerciseNumber = (index) => { checkExerciseNumber=(index)=>{
let url = `/exercises/${this.props.match.params.Id}/begin_commit.json`; let url= `/exercises/${this.props.match.params.Id}/begin_commit.json`;
axios.get(url).then((result) => { axios.get(url).then((result)=>{
if (result) { if(result){
if (result.data.question_undo != 0 || result.data.shixun_undo != 0) { if(result.data.question_undo !=0 || result.data.shixun_undo !=0) {
let tip = ""; let tip="";
if (result.data.question_undo != 0 && result.data.shixun_undo != 0) { if(result.data.question_undo !=0 && result.data.shixun_undo !=0){
tip = `${result.data.question_undo} 题未答,${result.data.shixun_undo} 实训未通关`; tip =`${result.data.question_undo} 题未答,${result.data.shixun_undo} 实训未通关`;
} else if (result.data.question_undo != 0 && result.data.shixun_undo == 0) { }else if(result.data.question_undo !=0 && result.data.shixun_undo ==0){
tip = `${result.data.question_undo} 题未答`; tip =`${result.data.question_undo} 题未答`;
} else if (result.data.question_undo == 0 && result.data.shixun_undo != 0) { }else if(result.data.question_undo ==0 && result.data.shixun_undo !=0){
tip = `${result.data.shixun_undo} 实训未通关`; tip =`${result.data.shixun_undo} 实训未通关`;
} }
this.setState({ this.setState({
Modalstype: true, Modalstype:true,
Modalstopval: tip, Modalstopval:tip,
modalsBottomval: index === 0 ? `${moment(result.data.end_time).format(format)}之前,允许修改答题` : `提交后无法再修改答题,是否确认提交?`, modalsBottomval:index === 0 ? `${moment(result.data.end_time).format(format)}之前,允许修改答题` : `提交后无法再修改答题,是否确认提交?`,
ModalCancel: this.cancelCommit, ModalCancel:this.cancelCommit,
ModalSave: () => this.sureCommitOrSave(index), ModalSave:()=>this.sureCommitOrSave(index),
Loadtype: index === 0 ? true : false Loadtype:index === 0 ? true :false
}) })
} else { }else{
this.setState({ this.setState({
Modalstype: true, Modalstype:true,
Modalstopval: index === 0 ? `${moment(result.data.end_time).format(format)}之前,允许修改答题` : `提交后无法再修改答题,是否确认提交?`, Modalstopval:index === 0 ? `${moment(result.data.end_time).format(format)}之前,允许修改答题` : `提交后无法再修改答题,是否确认提交?`,
modalsBottomval: undefined, modalsBottomval:undefined,
ModalCancel: this.cancelCommit, ModalCancel:this.cancelCommit,
ModalSave: () => this.sureCommitOrSave(index), ModalSave:()=>this.sureCommitOrSave(index),
Loadtype: index === 0 ? true : false Loadtype:index === 0 ? true :false
}) })
} }
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} }
//交卷 //交卷
commitExercise = () => { commitExercise=()=>{
this.checkExerciseNumber(1); this.checkExerciseNumber(1);
} }
//保存 //保存
saveExercise = () => { saveExercise=()=>{
this.checkExerciseNumber(0); this.checkExerciseNumber(0);
} }
//确认交卷或者保存 //确认交卷或者保存
sureCommitOrSave = (index) => { sureCommitOrSave=(index)=>{
if (index === 0) { if(index===0){
//确认保存 //确认保存
this.cancelCommit(); this.cancelCommit();
this.sureCommit(); this.sureCommit();
} else { }else{
//交卷 //交卷
let eId = this.props.match.params.Id; let eId=this.props.match.params.Id;
let url = `/exercises/${eId}/commit_exercise.json`; let url=`/exercises/${eId}/commit_exercise.json`;
axios.post(url, { axios.post(url,{
commit_method: 1 commit_method:1
}).then((result) => { }).then((result)=>{
if (result) { if(result){
this.setState({ this.setState({
Modalstype: false, Modalstype:false,
Modalstopval: undefined, Modalstopval:undefined,
modalsBottomval: undefined, modalsBottomval:undefined,
ModalCancel: undefined, ModalCancel:undefined,
ModalSave: undefined, ModalSave:undefined,
Loadtype: undefined Loadtype:undefined
}) })
this.props.showNotification(`${result.data.message}`); this.props.showNotification(`${result.data.message}`);
this.getInfo(); this.getInfo();
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} }
} }
cancelCommit = () => { cancelCommit=()=>{
this.setState({ this.setState({
Modalstype: false, Modalstype:false,
Modalstopval: undefined, Modalstopval:undefined,
modalsBottomval: undefined, modalsBottomval:undefined,
ModalCancel: undefined, ModalCancel:undefined,
ModalSave: undefined, ModalSave:undefined,
Loadtype: undefined Loadtype:undefined
}) })
} }
// 打回重做 // 打回重做
RepeatExercise = () => { RepeatExercise=()=>{
let status = parseInt(this.state.exercise.exercise_status); let status=parseInt(this.state.exercise.exercise_status);
if (status === 3) { if(status === 3){
this.setState({ this.setState({
Modalstype: true, Modalstype:true,
Modalstopval: '截止时间已到,无法打回试卷', Modalstopval:'截止时间已到,无法打回试卷',
modalsBottomval: '请在修改截止时间后再操作', modalsBottomval:'请在修改截止时间后再操作',
ModalCancel: this.cancelCommit, ModalCancel:this.cancelCommit,
ModalSave: this.cancelCommit, ModalSave:this.cancelCommit,
Loadtype: true Loadtype:true
}) })
} else { }else{
this.setState({ this.setState({
Modalstype: true, Modalstype:true,
Modalstopval: '学生将得到一次重新答题的机会,现有的答题情况将被清空', Modalstopval:'学生将得到一次重新答题的机会,现有的答题情况将被清空',
modalsBottomval: '是否确认回退TA的试卷答题', modalsBottomval:'是否确认回退TA的试卷答题',
ModalCancel: this.cancelCommit, ModalCancel:this.cancelCommit,
ModalSave: this.sureRepeatExercise, ModalSave:this.sureRepeatExercise,
Loadtype: false Loadtype:false
}) })
} }
} }
sureRepeatExercise = () => { sureRepeatExercise=()=>{
let eId = this.props.match.params.Id; let eId=this.props.match.params.Id;
let user_id = this.state.Id; let user_id=this.state.Id;
let url = `/exercises/${eId}/redo_exercise.json` let url=`/exercises/${eId}/redo_exercise.json`
axios.post((url), { axios.post((url),{
user_ids: [user_id] user_ids:[user_id]
}).then((result) => { }).then((result)=>{
if (result) { if(result){
this.props.showNotification(`${result.data.message}`); this.props.showNotification(`${result.data.message}`);
//打回重做后跳转到答题列表页 //打回重做后跳转到答题列表页
this.sureCommit(); this.sureCommit();
} }
}).catch((error) => { }).catch((error)=>{
console.log(error); console.log(error);
}) })
} }
@ -588,24 +586,24 @@ class ExerciseReviewAndAnswer extends Component {
this.props.history.push(`/classrooms/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`) this.props.history.push(`/classrooms/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`)
} }
deadline = (time) => { deadline=(time)=>{
if (time === null) { if(time===null){
this.setState({ this.setState({
Datetime: 0 Datetime:0
}) })
} else { }else{
this.setState({ this.setState({
Datetime: Date.now() + time * 1000 Datetime:Date.now() + time * 1000
}) })
// return Date.now() + time * 1000 ; // return Date.now() + time * 1000 ;
} }
} }
render() { render(){
let coursesId = this.props.match.params.coursesId; let coursesId=this.props.match.params.coursesId;
let eId = this.props.match.params.Id; let eId=this.props.match.params.Id;
let { let{
data, data,
questionPanelFixed, questionPanelFixed,
courseName, courseName,
@ -637,14 +635,15 @@ class ExerciseReviewAndAnswer extends Component {
exerciseTotalScore, exerciseTotalScore,
isSpin, isSpin,
ajustSore ajustSore
} = this.state }=this.state
let isAdmin = this.props.isAdmin(); let isAdmin = this.props.isAdmin();
let isStudent = this.props.isStudent(); let isStudent =this.props.isStudent();
const { current_user } = this.props const { current_user } = this.props
// console.log(data&&data.exercise.user_name) // console.log(data&&data.exercise.user_name)
document.title = courseName && courseName; document.title=courseName&&courseName;
return (<div className="newMain" style={{ paddingTop: "0px" }}> return(
<div className="newMain" style={{paddingTop:"0px"}}>
<Spin size="large" spinning={isSpin}> <Spin size="large" spinning={isSpin}>
<style>{` <style>{`
.inputNumber30{ .inputNumber30{
@ -698,14 +697,14 @@ class ExerciseReviewAndAnswer extends Component {
<CoursesListType typelist={[`${statudmap[exercise && exercise.exercise_status]}`]} typesylename={""} /> <CoursesListType typelist={[`${statudmap[exercise && exercise.exercise_status]}`]} typesylename={""} />
</span> </span>
{ {
(isAdmin || (isStudent && exercise && user_exercise_status == 1)) ? (isAdmin || ( isStudent && exercise && user_exercise_status == 1)) ?
<WordsBtn className="fr font-16 lineh-40" style="grey" onClick={this.returnBtn}>返回</WordsBtn> <WordsBtn className="fr font-16 lineh-40" style="grey" onClick={this.returnBtn}>返回</WordsBtn>
: :
time && time != 0 ? time && time != 0 ?
<div className="fr"> <div className="fr">
<Countdown value={this.state.Datetime} onFinish={this.autoCommitExercise} /> <Countdown value={this.state.Datetime} onFinish={this.autoCommitExercise} />
</div> </div>
: "" :""
} }
{/*<div className="fr remainingTime">*/} {/*<div className="fr remainingTime">*/}
{/* <li>{ hour >= 10 ? hour : '0'+hour}</li>*/} {/* <li>{ hour >= 10 ? hour : '0'+hour}</li>*/}
@ -747,15 +746,15 @@ class ExerciseReviewAndAnswer extends Component {
exercise_types && exercise_types.q_shixuns > 0 && exercise_types && exercise_types.q_shixuns > 0 &&
<span className="color-grey-9 mr15">实训题 {exercise_types.q_shixuns} , {exercise_types && exercise_types.q_shixuns_scores} </span> <span className="color-grey-9 mr15">实训题 {exercise_types.q_shixuns} , {exercise_types && exercise_types.q_shixuns_scores} </span>
} }
<span className="color-grey-3 fr"><span className="color-orange-tip"> {exercise_types && exercise_types.q_scores} </span></span> <span className="color-grey-3 fr"><span className="color-orange-tip"> {exercise_types &&exercise_types.q_scores} </span></span>
<span className="color-grey-3 fr">合计<span className="color-blue"> {exercise_types && exercise_types.q_counts} </span></span> <span className="color-grey-3 fr">合计<span className="color-blue"> {exercise_types &&exercise_types.q_counts} </span></span>
</p> </p>
<div className="edu-back-white"> <div className="edu-back-white">
<div className={questionPanelFixed == true ? "questionsfixed padding30" : "questionsNo padding30"} style={{ borderBottom: "none" }}> <div className={ questionPanelFixed==true ? "questionsfixed padding30":"questionsNo padding30"} style={{borderBottom:"none"}}>
<span className="clearfix font-16"> <span className="clearfix font-16">
{ {
exercise_start_at && <span className="fl color-grey-9">开始答题时间{exercise_start_at && moment(exercise_start_at).format(format)}</span> exercise_start_at && <span className="fl color-grey-9">开始答题时间{ exercise_start_at && moment(exercise_start_at).format(format) }</span>
} }
{ {
(isAdmin || (isStudent && exercise && exercise.exercise_status == 3)) && exerciseTotalScore && (isAdmin || (isStudent && exercise && exercise.exercise_status == 3)) && exerciseTotalScore &&
@ -777,9 +776,9 @@ class ExerciseReviewAndAnswer extends Component {
</p> </p>
<ul className="clearfix leaderMainNav mb20"> <ul className="clearfix leaderMainNav mb20">
{ {
exercise_scores.objective_scores.map((item, key) => { exercise_scores.objective_scores.map((item,key)=>{
return ( return(
<a className={item.answer_status == 1 ? "acted" : item.answer_status == 2 ? "half" : ""} onClick={() => this.scrollToAnchor(`${item.ques_position}`)}>{item.ques_position}</a> <a className={item.answer_status==1? "acted" : item.answer_status==2? "half" :""} onClick={()=>this.scrollToAnchor(`${item.ques_position}`)}>{item.ques_position}</a>
) )
}) })
} }
@ -796,9 +795,9 @@ class ExerciseReviewAndAnswer extends Component {
</p> </p>
<ul className="clearfix leaderNav"> <ul className="clearfix leaderNav">
{ {
exercise_scores.subjective_scores.map((item, key) => { exercise_scores.subjective_scores.map((item,key)=>{
return ( return(
<a className={item.answer_status == 0 ? "" : "acted"} onClick={() => this.scrollToAnchor(`${item.ques_position}`)}>{item.ques_position}</a> <a className={item.answer_status==0 ? "" : "acted"} onClick={()=>this.scrollToAnchor(`${item.ques_position}`)}>{item.ques_position}</a>
) )
}) })
} }
@ -818,23 +817,23 @@ class ExerciseReviewAndAnswer extends Component {
</p> </p>
<ul className="clearfix leaderNav"> <ul className="clearfix leaderNav">
{ {
question_status && question_status.map((item, key) => { question_status && question_status.map((item,key)=>{
return ( return(
<a className={item.ques_status == 1 ? "acted" : ""} onClick={() => this.scrollToAnchor(`${item.ques_number}`)}>{item.ques_number}</a> <a className={item.ques_status == 1 ? "acted" : ""} onClick={()=>this.scrollToAnchor(`${item.ques_number}`)}>{item.ques_number}</a>
) )
}) })
} }
</ul> </ul>
</div> : "" </div>:""
} }
</div> </div>
{/* 试卷题目 */} {/* 试卷题目 */}
<div> <div>
{ {
exercise_questions && exercise_questions.map((item, key) => { exercise_questions && exercise_questions.map((item,key)=>{
let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id); let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id);
return ( return(
<div className="bor-top-greyE pt30 pb30" id={"Anchor_" + parseInt(key + 1)}> <div className="bor-top-greyE pt30 pb30" id={"Anchor_"+parseInt(key+1)}>
<p className="clearfix font-16 pl30 pr30"> <p className="clearfix font-16 pl30 pr30">
<span className="color-blue mr5">{item.q_position}{type[item.question_type]}</span><span className="color-grey-9 mr5">({item.question_score})</span> <span className="color-blue mr5">{item.q_position}{type[item.question_type]}</span><span className="color-grey-9 mr5">({item.question_score})</span>
<span className="fr"> <span className="fr">
@ -852,20 +851,20 @@ class ExerciseReviewAndAnswer extends Component {
// 客观题:老师||学生(试卷已截止且答案公开)显示正确答案 // 客观题:老师||学生(试卷已截止且答案公开)显示正确答案
item.question_type < 3 && item.standard_answer_show ? item.question_type < 3 && item.standard_answer_show ?
<span className="font-16 fl ml20"> <span className="font-16 fl ml20">
正确答案{item.standard_answer_show} 正确答案{ item.standard_answer_show }
</span> : "" </span>:""
} }
{ {
//(老师身份且除实训题外) || (学生身份且试卷已经截止)就显示用户当前题目所得分数 //(老师身份且除实训题外) || (学生身份且试卷已经截止)就显示用户当前题目所得分数
(isAdmin || (isStudent && exercise.exercise_status == 3)) && item.question_type != 5 && item.user_score ? ( isAdmin || (isStudent && exercise.exercise_status == 3)) && item.question_type != 5 && item.user_score ?
<span className="font-16 ml20 fl"> <span className="font-16 ml20 fl">
<span><span className={parseInt(item.answer_status) == 0 ? "color-red" : parseInt(item.answer_status) == 1 ? "color-green" : "color-orange-tip"}>{item.user_score}</span> </span> <span><span className={parseInt(item.answer_status) == 0 ?"color-red":parseInt(item.answer_status) == 1 ?"color-green":"color-orange-tip"}>{item.user_score}</span> </span>
</span> : "" </span> : ""
} }
{ {
//实训题 ,答题 //实训题 ,答题
item.question_type == 5 && item.question_type == 5 &&
<a href={"/shixuns/" + item.shixun_identifier + "/challenges"} target="_blank" class="font-16 color-blue fl" target={"_blank"}>实训详情</a> <a href={"/shixuns/"+item.shixun_identifier+"/challenges"} target="_blank" class="font-16 color-blue fl" target={"_blank"}>实训详情</a>
} }
</span> </span>
</p> </p>
@ -898,8 +897,8 @@ class ExerciseReviewAndAnswer extends Component {
exercise={exercise} exercise={exercise}
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeOption={(index, ids) => this.changeOption(index, ids)} changeOption={(index,ids)=>this.changeOption(index,ids)}
changeQuestionStatus={(No, flag) => this.changeQuestionStatus(No, flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key} index={key}
></Multiple> ></Multiple>
@ -982,12 +981,17 @@ class ExerciseReviewAndAnswer extends Component {
></InputNumber> ></InputNumber>
<span className="ml5"></span> <span className="ml5"></span>
{ {
list && list.length > 0 && list[0].setTip != "" ? <p className="color-red edu-txt-left">{list[0].setTip}</p> : "" parseInt(item.answer_status) == 0 && item.question_type == 4 ? <span className="color-red ml10 font-16">未评分</span> : ''
}
<ActionBtn style="blue" className="middle ml20" onClick={()=>this.setAction(key,item.question_id,item.question_score,item.user_score)}>确认</ActionBtn>
</p>
{
list && list.length > 0 && list[0].setTip !="" ? <p className="color-red edu-txt-left">{ list[0].setTip }</p> :""
} }
</li> </li>
</div> </div>
<Textarea className="winput-100-150 mt20" value={list && list.length > 0 && list[0].desc} style={{ height: "180px" }} maxLength="100" onChange={(e) => this.changeScoreReasons(e, item.question_id)} placeholder="请您输入评语最大限制100个字符"></Textarea> <Textarea className="winput-100-150 mt20" value={list && list.length>0 && list[0].desc} style={{height:"180px"}} maxLength="100" onChange={(e)=>this.changeScoreReasons(e,item.question_id)} placeholder="请您输入评语最大限制100个字符"></Textarea>
</div> : "" </div>:""
} }
</div> </div>
) )
@ -1003,9 +1007,9 @@ class ExerciseReviewAndAnswer extends Component {
{ {
exercise && time != null ? exercise && time != null ?
<span className="color-grey-9 font-12 mr20 fr lineh-40">保存或者离开页面后系统将持续计时到达时长系统将自动交卷</span> <span className="color-grey-9 font-12 mr20 fr lineh-40">保存或者离开页面后系统将持续计时到达时长系统将自动交卷</span>
: "" :""
} }
</p> : "" </p>:""
} }
</div> </div>
</Spin> </Spin>

@ -367,7 +367,6 @@ class NullEditor extends Component {
</div> </div>
</div>
) )
} }
} }

Loading…
Cancel
Save