From 4247476e5c03b668fdf8fd7845bb19f277ddfaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 11 Nov 2019 10:46:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=B0=83=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coursesPublic/ModulationModal_exercise.js | 504 +++++++++++++++--- .../courses/coursesPublic/Newshixunmodel.css | 2 +- .../exercise/Studentshavecompletedthelist.js | 37 +- 3 files changed, 465 insertions(+), 78 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js b/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js index 538b32773..a9e54a62c 100644 --- a/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js +++ b/public/react/src/modules/courses/coursesPublic/ModulationModal_exercise.js @@ -11,21 +11,209 @@ class ModulationModal_exercise extends Component { score: 0, subjective_questions: 0, objective_questions: 0, - + subjective_score: 0, + objective_score: 0, + subool: false, + Inputsval: '', + Inputsvals: '', + Inputsvaltype: false, + Inputsvaltypes: false, + Inputsvaltest: "", + Inputsvaltests: "", } //因为主观题加客观题的和是总分 } componentDidMount = () => { - + console.log("ModulationModal_exercise"); + console.log(this.props); + this.setState({ + subjective_score: this.props.subjective_score, + objective_score: this.props.objective_score, + }) + if (this.props.subjective_score > 0 && this.props.objective_score > 0) { + this.setState({ + subool: false, + }) + } else { + this.setState({ + subool: true + }) + } } Saves = () => { - let {textareaval, subjective_questions, objective_questions, score} = this.state; + let { + textareaval, + subjective_questions, + objective_questions, + score, + subool, + Inputsval, + subjective_score, + objective_score, + Inputsvals + } = this.state; + let re = /^[0-9]+.?[0-9]*$/;//判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/ + + if (subool === false) { + //不是总分模式 + if (Inputsval === undefined || Inputsval === null || Inputsval === "") { + this.setState({ + Inputsval: "", + Inputsvaltype: true, + Inputsvaltest: "请填写分数", + }) + return + } + + //判断主观题 + + var nubmer = Inputsval; + if (!re.test(nubmer)) { + this.setState({ + Inputsval: Inputsval, + Inputsvaltype: true, + Inputsvaltest: "请输入0-100的分数", + }) + return; + } + + + if (0 > parseFloat(Inputsval)) { + this.setState({ + Inputsval: Inputsval, + Inputsvaltype: true, + Inputsvaltest: "成绩不能小于零", + }) + return; + } else if (parseFloat(Inputsval) > this.props.subjective_score) { + this.setState({ + Inputsval: Inputsval, + Inputsvaltype: true, + Inputsvaltest: `成绩不能大于${this.props.subjective_score}`, + }) + return; + } + //判断客观题 + if (Inputsvals === undefined || Inputsvals === null || Inputsvals === "") { + this.setState({ + Inputsvals: "", + Inputsvaltypes: true, + Inputsvaltests: "请填写分数", + }) + return + } + var nubmers = Inputsvals; + if (!re.test(nubmers)) { + this.setState({ + Inputsvals: "", + Inputsvaltypes: true, + Inputsvaltests: "请输入0-100的分数", + }) + return; + } + + if (0 > parseFloat(Inputsvals)) { + this.setState({ + Inputsvals: Inputsvals, + Inputsvaltypes: true, + Inputsvaltests: "请输入0-100的分数", + }) + return; + } else if (parseFloat(Inputsval) > 100) { + this.setState({ + Inputsvals: Inputsvals, + Inputsvaltypes: true, + Inputsvaltests: `成绩不能大于${this.props.objective_score}`, + }) + return; + } - // this.props.Saves(textareaval, Inputsval) + + } else { + //总分模式 + if (subjective_score > 0) { + //主观题 + if (Inputsval === undefined || Inputsval === null || Inputsval === "") { + this.setState({ + Inputsval: "", + Inputsvaltype: true, + Inputsvaltest: "请填写分数", + }) + return + } + + //判断主观题 + var nubmer = Inputsval; + if (!re.test(nubmer)) { + this.setState({ + Inputsval: Inputsval, + Inputsvaltype: true, + Inputsvaltest: "请输入0-100的分数", + }) + return; + } + + + if (0 > parseFloat(Inputsval)) { + this.setState({ + Inputsval: Inputsval, + Inputsvaltype: true, + Inputsvaltest: "成绩不能小于零", + }) + return; + } else if (parseFloat(Inputsval) > this.props.subjective_score) { + this.setState({ + Inputsval: Inputsval, + Inputsvaltype: true, + Inputsvaltest: `成绩不能大于${this.props.subjective_score}`, + }) + return; + } + } else if (objective_score > 0) { + //客观题 + if (Inputsvals === undefined || Inputsvals === null || Inputsvals === "") { + this.setState({ + Inputsvals: "", + Inputsvaltypes: true, + Inputsvaltests: "请填写分数", + }) + return + } + var nubmers = Inputsvals; + if (!re.test(nubmers)) { + this.setState({ + Inputsvals: "", + Inputsvaltypes: true, + Inputsvaltests: "请输入0-100的分数", + }) + return; + } + + if (0 > parseFloat(Inputsvals)) { + this.setState({ + Inputsvals: Inputsvals, + Inputsvaltypes: true, + Inputsvaltests: "请输入0-100的分数", + }) + return; + } else if (parseFloat(Inputsvals) > 100) { + this.setState({ + Inputsvals: Inputsvals, + Inputsvaltypes: true, + Inputsvaltests: `成绩不能大于${this.props.objective_score}`, + }) + return; + } + + } + } + + + this.props.Saves(Inputsval, Inputsvals); } @@ -35,13 +223,57 @@ class ModulationModal_exercise extends Component { }) } + //主观题 setInputs = (e) => { + console.log("主"); + console.log(e.target.value); + this.setState({ + Inputsval: e.target.value, + Inputsvaltype: false, + }) + } + //客观题 + setInputss = (e) => { + console.log("客"); + console.log(e.target.value); + this.setState({ + Inputsvals: e.target.value, + Inputsvaltypes: false, + + }) + } + //最终成绩主观题 + setInputsss = (e) => { + console.log("终主"); + console.log(e.target.value); + this.setState({ + Inputsval: e.target.value, + Inputsvaltype: false, + }) + } + //最终成绩客观题 + setInputssss = (e) => { + console.log("终客"); + console.log(e.target.value); + this.setState({ + Inputsvals: e.target.value, + Inputsvaltypes: false, + }) } render() { - let {Inputsvaltype, subjective_questions, objective_questions, score} = this.state; + let { + Inputsvaltype, + Inputsvaltypes, + Inputsvaltest, + Inputsvaltests, + subjective_score, + objective_score, + Inputsval, + Inputsvals, + } = this.state; return (
+ { + subjective_score > 0 && objective_score > 0 ? +
+ {Inputsvaltype === true ? + + : + "" -
-

主观题成绩:

- this.setInputs(e)} - value={subjective_questions === undefined || subjective_questions === null ? "" : subjective_questions}/> -

分 ,

-

总分:45.0

-
- -
- -

客观题成绩:

- this.setInputs(e)} - value={objective_questions === undefined || objective_questions === null ? "" : objective_questions}/> -

分 ,

-

总分:45.0

- -
- -
-

最终成绩:

- this.setInputs(e)} - value={score === undefined || score === null ? "" : score}/> -

分 ,

-

总分:45.0

- -
- - -
- {this.props.Cancelname || '取消'} - {this.props.Savesname || '保存'} -
+ } +
+

主观题成绩:

+ +

分 ,

+

总分:{subjective_score}

+
+ { + Inputsvaltype === true ? +

{Inputsvaltest}

+ : "" + } + {Inputsvaltypes === true ? + + : + "" -
+ } +
+ +

客观题成绩:

+ +

分 ,

+

总分:{objective_score}

+ +
+ { + Inputsvaltypes === true ? +

{Inputsvaltests}

+ : "" + } +
+ : +
+ { + subjective_score > 0 && objective_score === 0 ? +
+ {Inputsvaltype === true ? + + : + "" + + } +
+

最终成绩:

+ +

分 ,

+

+ 总分:{subjective_score > 0 && objective_score === 0 ? subjective_score : ""} {objective_score > 0 && subjective_score === 0 ? objective_score : ""}

+
+ { + Inputsvaltype === true ? +

{Inputsvaltest}

+ : "" + } +
+ : + "" + } + { + objective_score > 0 && subjective_score === 0 ? +
+ {Inputsvaltypes === true ? + + : + "" + } +
+

最终成绩:

+ +

分 ,

+

+ 总分:{subjective_score > 0 && objective_score === 0 ? subjective_score : ""} {objective_score > 0 && subjective_score === 0 ? objective_score : ""}

+ +
+ { + Inputsvaltypes === true ? +

{Inputsvaltests}

+ : "" + } +
+ : + "" + } + + +
+ {this.props.Cancelname || '取消'} + {this.props.Savesname || '保存'} +
+
+ + } + ) diff --git a/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css b/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css index 34721fa21..30cb300c8 100644 --- a/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css +++ b/public/react/src/modules/courses/coursesPublic/Newshixunmodel.css @@ -361,7 +361,7 @@ .minbuttionte { /* display: flex; */ - margin-top: 27px; + margin-top: 20px; width: 100%; /* align-items: center; */ margin-bottom: 17px; diff --git a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js index a787575e1..5b2150457 100644 --- a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js +++ b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js @@ -2598,9 +2598,11 @@ class Studentshavecompletedthelist extends Component { } // 调分 Adjustment = (e) => { + console.log("Adjustment"); + console.log(e); this.setState({ testpapergradingboll: true, - exeuserid: e.user_id, + exeuserid: e, }) } @@ -2615,12 +2617,13 @@ class Studentshavecompletedthelist extends Component { //试卷调分 Testpapergrading = (v, n) => { + // debugger var exercise_id = this.props.match.params.Id; let url = `/exercises/${exercise_id}/adjust_score.json`; axios.post(url, { user_id: this.state.exeuserid, - subjective_score: n, - objective_score: v, + subjective_score: v, + objective_score: n, }) .then((response) => { if (response.data.status == '0') { @@ -2629,7 +2632,7 @@ class Studentshavecompletedthelist extends Component { this.Teacherliststudentlist(); } }) - .catch(function (error) { + .catch((error) => { console.log(error); this.setState({testpapergradingboll: false}) }); @@ -2666,18 +2669,20 @@ class Studentshavecompletedthelist extends Component { :
- {testpapergradingboll === true ? this.Adjustments()} - Saves={(value, num) => this.Testpapergrading(value, num)} - /> : ""} - {/*{*/} - {/* testpapergradingboll === true ? this.Adjustments()}*/} - {/* Saves={(value, num) => this.Testpapergrading(value, num)}*/} - {/* /> : ""*/} - {/*}*/} + {/*{testpapergradingboll === true ? this.Adjustments()}*/} + {/* Saves={(value, num) => this.Testpapergrading(value, num)}*/} + {/*/> : ""}*/} + { + testpapergradingboll === true ? this.Adjustments()} + Saves={(value, num) => this.Testpapergrading(value, num)} + /> : "" + }