|
|
|
@ -81,10 +81,10 @@ class LeftViewContainer extends Component {
|
|
|
|
|
if ( tabIndex === 2 && this.state.gameAnswer === '') { // 参考答案
|
|
|
|
|
// 多级答案后换了接口
|
|
|
|
|
// 选择题(st === 1)还是走以前的接口
|
|
|
|
|
if (true || (this.props.st === 0)) {
|
|
|
|
|
if ((this.props.st === 0)) {
|
|
|
|
|
this.fetchIfCouldGetAnswerWithoutGoldForMultiLevelAnswer()
|
|
|
|
|
} else if (this.props.st === 1) {
|
|
|
|
|
this.fetchIfCouldGetAnswerWithoutGold();
|
|
|
|
|
this.fetchIfCouldGetAnswerWithoutGoldForChoose();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -337,7 +337,41 @@ class LeftViewContainer extends Component {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
fetchIfCouldGetAnswerWithoutGold() {
|
|
|
|
|
// 选择题查看答案
|
|
|
|
|
fetchIfCouldGetAnswerWithoutGoldForChoose() {
|
|
|
|
|
const url = `/tasks/${this.props.game.identifier}/get_choose_answer.json`
|
|
|
|
|
axios.get(url, {
|
|
|
|
|
// withCredentials: true,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
|
|
|
|
|
if (response.data.status == 0) {
|
|
|
|
|
this.props.showSnackbar(response.data.message)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
将扣除XXX点金币,是否确认查看答案
|
|
|
|
|
|
|
|
|
|
已经过职业认证的教师可以免金币查看答案哟
|
|
|
|
|
继续查看 立即认证(新开页)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 答案测试 TODO
|
|
|
|
|
// if (false && response.data.view_answer === true) {
|
|
|
|
|
if (response.data.choose_answers) {
|
|
|
|
|
this.showAnswer(response.data.choose_answers)
|
|
|
|
|
} else if (response.data.status == 1) {
|
|
|
|
|
// 三个角色 普通用户、未认证教师、已认证教师,这里要区分普通用户和未认证教师用户
|
|
|
|
|
this.setState({
|
|
|
|
|
dialogOpen: true,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
// 查看是否有权限直接查看,true可以直接查看,false需要扣金币查看
|
|
|
|
|
// var getAnswerUrl = `/api/v1/games/${this.props.game.identifier}/answer`;
|
|
|
|
|
var getAnswerUrl = `/tasks/${this.props.game.identifier}/answer.json`
|
|
|
|
@ -445,6 +479,7 @@ class LeftViewContainer extends Component {
|
|
|
|
|
const challenge_score = this.props.challenge.score
|
|
|
|
|
// 前端计算扣除金币数
|
|
|
|
|
let goldToMinuse = 0
|
|
|
|
|
if (this.state.isMultiLevelAnswer) {
|
|
|
|
|
for (let i = 0; i < lockedAnswers.length; i++) {
|
|
|
|
|
let answer = lockedAnswers[i];
|
|
|
|
|
goldToMinuse = goldToMinuse + answer.score * challenge_score / 100;
|
|
|
|
@ -452,6 +487,9 @@ class LeftViewContainer extends Component {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
goldToMinuse = challenge_score
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.props.readGameAnswer({
|
|
|
|
|
grade: this.props.grade - goldToMinuse
|
|
|
|
@ -474,24 +512,12 @@ class LeftViewContainer extends Component {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
handleDialogReadAnswer(selectID) {
|
|
|
|
|
|
|
|
|
|
this.handleMultiLevelAnswer(selectID || this.state.singleAnswerId)
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
|
|
if (this.state.isMultiLevelAnswer) {
|
|
|
|
|
}
|
|
|
|
|
if (selectID) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// var getAnswerUrl = `/api/v1/games/${this.props.game.identifier}/answer_grade`
|
|
|
|
|
var getAnswerUrl = `/tasks/${this.props.game.identifier}/answer_grade.json`
|
|
|
|
|
|
|
|
|
|
axios.get(getAnswerUrl, {
|
|
|
|
|
getChooseAnswer = () => {
|
|
|
|
|
const url = `/tasks/${this.props.game.identifier}/unlock_choose_answer.json`
|
|
|
|
|
axios.get(url, {
|
|
|
|
|
// withCredentials: true,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
|
|
|
|
|
// {message: "您没有足够的金币", status: -1}
|
|
|
|
|
|
|
|
|
|
if (response.data.status == 0) {
|
|
|
|
@ -499,14 +525,13 @@ class LeftViewContainer extends Component {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const gameAnswer = response.data.answer;
|
|
|
|
|
const final_score = response.data.final_score;
|
|
|
|
|
const gameAnswer = response.data.choose_answers;
|
|
|
|
|
// const final_score = response.data.final_score;
|
|
|
|
|
const grade = response.data.grade;
|
|
|
|
|
|
|
|
|
|
this.props.readGameAnswer({
|
|
|
|
|
final_score,
|
|
|
|
|
grade,
|
|
|
|
|
// final_score,
|
|
|
|
|
grade: this.props.grade - this.props.challenge.score
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.showAnswer(gameAnswer)
|
|
|
|
@ -516,6 +541,14 @@ class LeftViewContainer extends Component {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
handleDialogReadAnswer(selectID) {
|
|
|
|
|
if (this.props.st === 1) {
|
|
|
|
|
// 选择题
|
|
|
|
|
this.getChooseAnswer()
|
|
|
|
|
} else {
|
|
|
|
|
this.handleMultiLevelAnswer(selectID || this.state.singleAnswerId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
createNewComment = (page) => {
|
|
|
|
|
const flag = this.props.createNewComment(page)
|
|
|
|
|
if (flag === true) {
|
|
|
|
|