|
|
|
@ -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(
|
|
|
|
|
<React.Fragment>
|
|
|
|
@ -428,6 +443,7 @@ class ExerciseNewCommon extends Component{
|
|
|
|
|
chooseShixun={this.chooseShixun}
|
|
|
|
|
{...this.props}
|
|
|
|
|
singleChoose={true}
|
|
|
|
|
shixunsUrl={this.props.shixunsUrl}
|
|
|
|
|
></ShixunChooseModal>
|
|
|
|
|
<style>{`
|
|
|
|
|
.courseForm .formBlock {
|
|
|
|
|