|
|
|
@ -77,7 +77,9 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
exerciseTotalScore:undefined,
|
|
|
|
|
|
|
|
|
|
// 加载效果
|
|
|
|
|
isSpin:false
|
|
|
|
|
isSpin:false,
|
|
|
|
|
// 调分数组
|
|
|
|
|
ajustSore:undefined
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
componentDidUpdate (prevProps) {
|
|
|
|
@ -190,7 +192,23 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
user_exercise_status:1,
|
|
|
|
|
Id:result.data.exercise_answer_user.user_id,
|
|
|
|
|
exerciseTotalScore:result.data.exercise_answer_user.score,
|
|
|
|
|
isSpin:false
|
|
|
|
|
isSpin:false,
|
|
|
|
|
})
|
|
|
|
|
// 先将未批的简答题放入到调分数组中
|
|
|
|
|
let ajustSore = [];
|
|
|
|
|
result.data && result.data.exercise_questions.length>0 && result.data.exercise_questions.map((item,key)=>{
|
|
|
|
|
if( item.question_type == 4 && item.answer_status == 0 ){
|
|
|
|
|
ajustSore.push({
|
|
|
|
|
inputSore:undefined,
|
|
|
|
|
desc:undefined,
|
|
|
|
|
id:item.question_id,
|
|
|
|
|
position:item.q_position,
|
|
|
|
|
setTip:""
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
ajustSore
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
@ -227,7 +245,7 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
}
|
|
|
|
|
scrollToAnchor=(index)=>{
|
|
|
|
|
let name="Anchor_"+index;
|
|
|
|
|
console.log($("#Anchor_"+index).scrollTop());
|
|
|
|
|
// console.log($("#Anchor_"+index).scrollTop());
|
|
|
|
|
if (index) {
|
|
|
|
|
// let anchorElement = document.getElementById(name);
|
|
|
|
|
// if(anchorElement) { anchorElement.scrollIntoView(); }
|
|
|
|
@ -244,62 +262,115 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
// 调分
|
|
|
|
|
showSetScore=(key,flag,setId)=>{
|
|
|
|
|
showSetScore=(key,flag,position,type,id)=>{
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
exercise_questions : update(prevState.exercise_questions, {[key]: { setScore: {$set: flag == undefined || flag==false ? true : false}}})
|
|
|
|
|
}),()=>{
|
|
|
|
|
if (setId && (flag == undefined || flag==false)) {
|
|
|
|
|
$("html").animate({ scrollTop: $("#Anchor_"+setId).offset().top - 150 })
|
|
|
|
|
if (position && type && (flag == undefined || flag==false)) {
|
|
|
|
|
$("html").animate({ scrollTop: $("#Anchor_"+position+"_"+type).offset().top - 150 });
|
|
|
|
|
|
|
|
|
|
if(id){
|
|
|
|
|
let { ajustSore } = this.state;
|
|
|
|
|
let obj = ajustSore.filter(obj => obj.id === id).length > 0;
|
|
|
|
|
if(!obj){
|
|
|
|
|
ajustSore.push({
|
|
|
|
|
id,
|
|
|
|
|
inputSore:undefined,
|
|
|
|
|
desc:undefined,
|
|
|
|
|
position:position,
|
|
|
|
|
setTip:""
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
this.setState({
|
|
|
|
|
score:undefined
|
|
|
|
|
})
|
|
|
|
|
// this.setState({
|
|
|
|
|
// score:undefined
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inputScore=(value)=>{
|
|
|
|
|
|
|
|
|
|
inputScore=(value,id)=>{
|
|
|
|
|
let { ajustSore } = this.state;
|
|
|
|
|
var index = ajustSore.map(function (item) { return item.id; }).indexOf(id);
|
|
|
|
|
let reg = /^[0-9]+.?[0-9]*$/;
|
|
|
|
|
if(reg.test(value)==false){
|
|
|
|
|
this.setState({
|
|
|
|
|
setTip:"请输入数字"
|
|
|
|
|
// this.setState({
|
|
|
|
|
// setTip:"请输入数字"
|
|
|
|
|
// })
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { setTip: {$set: "请输入数字"}}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
return;
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
setTip:"",
|
|
|
|
|
score:value
|
|
|
|
|
// this.setState({
|
|
|
|
|
// setTip:"",
|
|
|
|
|
// score:value
|
|
|
|
|
// })
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { inputSore: {$set: value},setTip:{$set: ""}}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
changeScoreReasons=(e)=>{
|
|
|
|
|
console.log(e.target.value);
|
|
|
|
|
this.setState({
|
|
|
|
|
setScoreReason:e.target.value
|
|
|
|
|
changeScoreReasons=(e,id)=>{
|
|
|
|
|
// console.log(e.target.value);
|
|
|
|
|
// this.setState({
|
|
|
|
|
// setScoreReason:e.target.value
|
|
|
|
|
// })
|
|
|
|
|
let value = e.target.value;
|
|
|
|
|
let { ajustSore } = this.state;
|
|
|
|
|
var index = ajustSore.map(function (item) { return item.id; }).indexOf(id);
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { desc: {$set: value}}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
//确认调分
|
|
|
|
|
setAction=(key,q_id,maxScore)=>{
|
|
|
|
|
let {ajustSore}=this.state;
|
|
|
|
|
let list = ajustSore.filter(obj => obj.id == q_id);
|
|
|
|
|
let index = ajustSore.map(function (item) { return item.id; }).indexOf(q_id);
|
|
|
|
|
|
|
|
|
|
let{ score,setScoreReason ,setTip }=this.state;
|
|
|
|
|
let score = list[0].inputSore;
|
|
|
|
|
let setScoreReason = list[0].desc;
|
|
|
|
|
let{ setTip }=this.state;
|
|
|
|
|
if(!score && score != 0){
|
|
|
|
|
this.setState({
|
|
|
|
|
setTip:"请输入分数"
|
|
|
|
|
// this.setState({
|
|
|
|
|
// setTip:"请输入分数"
|
|
|
|
|
// })
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { setTip: {$set: "请输入分数"}}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(score < 0){
|
|
|
|
|
this.setState({
|
|
|
|
|
setTip:"分数必须大于或者等于0"
|
|
|
|
|
// this.setState({
|
|
|
|
|
// setTip:"分数必须大于或者等于0"
|
|
|
|
|
// })
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { setTip: {$set: "分数必须大于或者等于0"}}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(score > maxScore){
|
|
|
|
|
this.setState({
|
|
|
|
|
setTip:"分数不能大于当前题目的分数"
|
|
|
|
|
// this.setState({
|
|
|
|
|
// setTip:"分数不能大于当前题目的分数"
|
|
|
|
|
// })
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { setTip: {$set: "分数不能大于当前题目的分数"}}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(setTip==""){
|
|
|
|
@ -311,20 +382,20 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
if(result.status==200){
|
|
|
|
|
this.props.showNotification('调分成功');
|
|
|
|
|
console.log(this.state.exercise_questions);
|
|
|
|
|
|
|
|
|
|
let statusScore = score==0 ? 0 : score > 0 && score < maxScore ? 2 : 1;
|
|
|
|
|
console.log(statusScore);
|
|
|
|
|
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
exercise_questions : update(prevState.exercise_questions, {[key]: { user_score: {$set: score},answer_status : {$set: statusScore},question_comments:{$set:result.data.question_comments} }}),
|
|
|
|
|
exercise_questions : update(prevState.exercise_questions, {[key]: { user_score: {$set: parseFloat(score).toFixed(1)},answer_status : {$set: statusScore},question_comments:{$set:result.data.question_comments} }}),
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
console.log(this.state.exercise_questions);
|
|
|
|
|
this.setState({
|
|
|
|
|
score:undefined,
|
|
|
|
|
setTip:"",
|
|
|
|
|
setScoreReason:undefined
|
|
|
|
|
|
|
|
|
|
this.setState(
|
|
|
|
|
(prevState) => ({
|
|
|
|
|
ajustSore : update(prevState.ajustSore, {[index]: { desc: {$set: undefined},inputSore:{ $set:undefined }}})
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
this.showSetScore(key,true);
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
@ -518,12 +589,13 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
ModalSave,
|
|
|
|
|
Loadtype,
|
|
|
|
|
exerciseTotalScore,
|
|
|
|
|
isSpin
|
|
|
|
|
isSpin,
|
|
|
|
|
ajustSore
|
|
|
|
|
}=this.state
|
|
|
|
|
let isAdmin = this.props.isAdmin();
|
|
|
|
|
let isStudent =this.props.isStudent();
|
|
|
|
|
const { current_user } = this.props
|
|
|
|
|
console.log(data&&data.exercise.user_name)
|
|
|
|
|
// console.log(data&&data.exercise.user_name)
|
|
|
|
|
return(
|
|
|
|
|
<div className="newMain" style={{paddingTop:"0px"}}>
|
|
|
|
|
<Spin size="large" spinning={isSpin}>
|
|
|
|
@ -709,6 +781,8 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
<div>
|
|
|
|
|
{
|
|
|
|
|
exercise_questions && exercise_questions.map((item,key)=>{
|
|
|
|
|
debugger;
|
|
|
|
|
let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id);
|
|
|
|
|
return(
|
|
|
|
|
<div className="bor-top-greyE pt30 pb30" id={"Anchor_"+parseInt(key+1)}>
|
|
|
|
|
<p className="clearfix font-16 pl30 pr30">
|
|
|
|
@ -716,32 +790,32 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
<span className="fr">
|
|
|
|
|
{
|
|
|
|
|
// 填空(一直都有调分),和简答题调分:老师身份 已经评分的才能出现调分按钮
|
|
|
|
|
isAdmin && ((parseInt(item.answer_status) != 0 && item.question_type == 4) || item.question_type == 3) ?
|
|
|
|
|
<WordsBtn style="blue" className="mr20 font-16 fl" onClick={()=>this.showSetScore(key,item.setScore,item.q_position+"_"+item.question_type)}>调分</WordsBtn>:""
|
|
|
|
|
isAdmin && ((parseInt(item.answer_status) != 0 && item.question_type == 4) || item.question_type == 3 || item.question_type == 1) ?
|
|
|
|
|
<WordsBtn style="blue" className="ml20 font-16 fl" onClick={()=>this.showSetScore(key,item.setScore,item.q_position,item.question_type,item.question_id)}>调分</WordsBtn>:""
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
// 简答题,未评分的显示未批
|
|
|
|
|
isAdmin && parseInt(item.answer_status) == 0 && item.question_type == 4 ?
|
|
|
|
|
<span className="color-red fl mr20">未批</span>:""
|
|
|
|
|
<span className="color-red fl ml20">未批</span>:""
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
// 客观题:老师||学生(试卷已截止且答案公开)显示正确答案
|
|
|
|
|
item.question_type < 3 && item.standard_answer_show ?
|
|
|
|
|
<span className="font-16 ml20">
|
|
|
|
|
<span className="font-16 fl ml20">
|
|
|
|
|
正确答案:{ item.standard_answer_show }
|
|
|
|
|
</span>:""
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
//(老师身份且除实训题外) || (学生身份且试卷已经截止)就显示用户当前题目所得分数
|
|
|
|
|
( isAdmin || (isStudent && exercise.exercise_status == 3)) && item.question_type != 5 && item.user_score ?
|
|
|
|
|
<span className="font-16 ml20">
|
|
|
|
|
<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> : ""
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
//实训题 ,答题
|
|
|
|
|
item.question_type == 5 &&
|
|
|
|
|
<a href={"/shixuns/"+item.shixun_identifier+"/challenges"} target="_blank" class="font-16 color-blue" target={"_blank"}>实训详情</a>
|
|
|
|
|
<a href={"/shixuns/"+item.shixun_identifier+"/challenges"} target="_blank" class="font-16 color-blue fl" target={"_blank"}>实训详情</a>
|
|
|
|
|
}
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
@ -825,7 +899,7 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
//调分理由部分
|
|
|
|
|
item.question_comments && item.question_comments.comment && (item.question_type == 3 || item.question_type == 4) &&
|
|
|
|
|
item.question_comments && item.question_comments.comment && (item.question_type == 3 || item.question_type == 4 || item.question_type == 1) &&
|
|
|
|
|
<div className="ml30 mr30 bor-top-greyE pt30 mt20 clearfix df">
|
|
|
|
|
<img src={getImageUrl(`images/${item.question_comments.user_picture}`)} width="48" height="48" className="radius mr10"/>
|
|
|
|
|
<div className="flex1">
|
|
|
|
@ -839,7 +913,7 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
// 调分输入部分
|
|
|
|
|
isAdmin && ((item.setScore && item.question_type == 3) || ((item.setScore || parseInt(item.answer_status) == 0) && item.question_type == 4))?
|
|
|
|
|
isAdmin && ((item.setScore && item.question_type == 3) || (item.setScore && item.question_type == 1) || ((item.setScore || parseInt(item.answer_status) == 0) && item.question_type == 4))?
|
|
|
|
|
<div className="ml30 mr30 bor-top-greyE pt20 mt20" id={`${"Anchor_"+item.q_position+"_"+item.question_type}`}>
|
|
|
|
|
<div className="edu-txt-right">
|
|
|
|
|
<span><span className="color-red">*</span>调分:</span>
|
|
|
|
@ -848,12 +922,12 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
<InputNumber
|
|
|
|
|
placeholder="请填写分数"
|
|
|
|
|
min={0}
|
|
|
|
|
max={item.question_score}
|
|
|
|
|
value={score}
|
|
|
|
|
// max={item.question_score}
|
|
|
|
|
value={list && list.length>0 && list[0].inputSore}
|
|
|
|
|
step={0.1}
|
|
|
|
|
precision={1}
|
|
|
|
|
className={ setTip !="" ? "edu-txt-center winput-115-40 fl mt3 noticeTip inputNumber30" : "edu-txt-center winput-115-40 fl mt3 inputNumber30"}
|
|
|
|
|
onChange={this.inputScore}
|
|
|
|
|
className={ list && list.length>0 && list[0].setTip !="" ? "edu-txt-center winput-115-40 fl mt3 noticeTip inputNumber30" : "edu-txt-center winput-115-40 fl mt3 inputNumber30"}
|
|
|
|
|
onChange={(value)=>this.inputScore(value,item.question_id)}
|
|
|
|
|
></InputNumber>
|
|
|
|
|
<span className="ml5">分</span>
|
|
|
|
|
{
|
|
|
|
@ -862,11 +936,11 @@ class ExerciseReviewAndAnswer extends Component{
|
|
|
|
|
<ActionBtn style="blue" className="middle ml20" onClick={()=>this.setAction(key,item.question_id,item.question_score)}>确认</ActionBtn>
|
|
|
|
|
</p>
|
|
|
|
|
{
|
|
|
|
|
setTip !="" ? <p className="color-red edu-txt-left">{setTip}</p> :""
|
|
|
|
|
list && list.length > 0 && list[0].setTip !="" ? <p className="color-red edu-txt-left">{ list[0].setTip }</p> :""
|
|
|
|
|
}
|
|
|
|
|
</li>
|
|
|
|
|
</div>
|
|
|
|
|
<Textarea className="winput-100-150 mt20" value={setScoreReason} style={{height:"180px"}} maxLength="100" onChange={this.changeScoreReasons} 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>
|
|
|
|
|