From 6e905c40f431a5a5552339899ba57368c8b3dace Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 31 Aug 2019 11:30:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coursesPublic/ShixunChooseModal.js | 4 +-- .../courses/coursesPublic/ShixunModal.js | 4 +-- .../courses/exercise/ExerciseNewCommon.js | 28 +++++++++++++++---- .../courses/exercise/new/JudgeEditor.js | 5 ++-- .../courses/exercise/new/MainEditor.js | 5 ++-- .../courses/exercise/new/NullEditor.js | 5 ++-- .../courses/exercise/new/ShixunEditor.js | 5 ++-- .../courses/exercise/new/SingleEditor.js | 5 ++-- 8 files changed, 41 insertions(+), 20 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js b/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js index 68a4c6efe..cca75fc86 100644 --- a/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js +++ b/public/react/src/modules/courses/coursesPublic/ShixunChooseModal.js @@ -37,7 +37,7 @@ class ShixunChooseModal extends Component{ hometypepvisible:loading }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url, { params: { @@ -76,7 +76,7 @@ class ShixunChooseModal extends Component{ }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url).then((result)=>{ if(result.status===200){ diff --git a/public/react/src/modules/courses/coursesPublic/ShixunModal.js b/public/react/src/modules/courses/coursesPublic/ShixunModal.js index 24bb7310e..bc0e58a64 100644 --- a/public/react/src/modules/courses/coursesPublic/ShixunModal.js +++ b/public/react/src/modules/courses/coursesPublic/ShixunModal.js @@ -25,7 +25,7 @@ class ShixunModal extends Component{ hometypepvisible:true, }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url).then((result)=>{ if(result.status===200){ @@ -51,7 +51,7 @@ class ShixunModal extends Component{ hometypepvisible:loading }) let coursesId=this.props.match.params.coursesId; - let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; + let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json"; axios.get(url, { params: { diff --git a/public/react/src/modules/courses/exercise/ExerciseNewCommon.js b/public/react/src/modules/courses/exercise/ExerciseNewCommon.js index 3475d6100..a9875523b 100644 --- a/public/react/src/modules/courses/exercise/ExerciseNewCommon.js +++ b/public/react/src/modules/courses/exercise/ExerciseNewCommon.js @@ -80,13 +80,15 @@ class ExerciseNewCommon extends Component{ fetchExercise = () => { const Id = this.props.match.params.Id - this.isEdit = !!Id - if (Id) { - const url = `/exercises/${Id}/edit.json` + this.isEdit = this.props.isEdit || !!Id + if (this.isEdit) { + const url = this.props.exercise_url ? `/${this.props.exercise_url }/${Id}.json` : `/exercises/${Id}/edit.json` axios.get(url) .then((response) => { - if (response.data.status == 0) { + if (response.data.exercise) { const { exercise, ...others } = response.data + exercise.exercise_name = exercise.exercise_name || exercise.name + exercise.exercise_description = exercise.exercise_description || exercise.description this.setState({ ...exercise, ...others, @@ -126,7 +128,8 @@ class ExerciseNewCommon extends Component{ const exercise_id = this.props.match.params.Id const courseId = this.props.match.params.coursesId if (this.isEdit) { - const editUrl = `/exercises/${exercise_id}.json` + // /exercise_banks/:id.json + const editUrl = `/${this.props.exercise_url ? this.props.exercise_url : 'exercises'}/${exercise_id}.json` axios.put(editUrl, { exercise_name, exercise_description @@ -380,6 +383,15 @@ class ExerciseNewCommon extends Component{ const courseId = this.props.match.params.coursesId this.props.history.push(`/courses/${courseId}/exercises/${exercise_id}/student_exercise_list?tab=2`) } + getAddQuestionUrl = () => { + const Id = this.props.match.params.Id + const url = this.props.exercise_url_questions ? `/${this.props.exercise_url_questions}.json` : `/exercises/${Id}/exercise_questions.json` + return url; + } + getEditQuestionUrl = (question_id) => { + const editUrl = this.props.exercise_url_questions ? `/${this.props.exercise_url_questions}/${question_id}.json` : `/exercise_questions/${question_id}.json` + return editUrl; + } render() { let { exercise_name, exercise_description, course_id, exercise_types, exercise_questions, left_banner_id } = this.state; @@ -419,7 +431,10 @@ class ExerciseNewCommon extends Component{ onSortUp: this.onSortUp, displayCount: exercise_questions.length, exercise_status: this.state.exercise_status, - exerciseIsPublish: this.state.exercise_status >= 2 + exerciseIsPublish: this.state.exercise_status >= 2, + + getAddQuestionUrl: this.getAddQuestionUrl, + getEditQuestionUrl: this.getEditQuestionUrl, } return( @@ -428,6 +443,7 @@ class ExerciseNewCommon extends Component{ chooseShixun={this.chooseShixun} {...this.props} singleChoose={true} + shixunsUrl={this.props.shixunsUrl} >