发送题库

dev_chen
杨树林 5 years ago
parent 658f7453b1
commit 0ce32a48eb

@ -46,7 +46,7 @@ debugType = "admin";
// 老师 // 老师
// debugType="teacher"; // debugType="teacher";
// 学生 // 学生
//debugType="student"; debugType="student";

@ -10,12 +10,13 @@ import moment from 'moment';
import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder'; import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder';
import Modals from '../../modals/Modals'; import Modals from '../../modals/Modals';
import CoursesListType from '../coursesPublic/CoursesListType'; import CoursesListType from '../coursesPublic/CoursesListType';
import QuillForEditor from "../../../common/quillForEditor";
import Multiple from './question/multiple'; import Multiple from './question/multiple';
import Single from './question/single'; import Single from './question/single';
import FillEmpty from './question/fillEmpty'; import FillEmpty from './question/fillEmpty';
import SimpleAnswer from './question/simpleAnswer'; import SimpleAnswer from './question/simpleAnswer';
import ShixunAnswer from './question/shixunAnswer'; import ShixunAnswer from './question/shixunAnswer';
import QuestionModalPicture from '../../question/component/QuestionModalPicture'
import update from 'immutability-helper'; import update from 'immutability-helper';
@ -37,7 +38,7 @@ const tagArray = [
const $ = window.$; const $ = window.$;
const statudmap={1:"未发布",2:"已发布",3:"已截止"} const statudmap={1:"未发布",2:"已发布",3:"已截止"}
const type=["单选题","多选题","判断题","填空题","简答题","实训题"] const type=["单选题","多选题","判断题","填空题","简答题","实训题","编程题"]
const format="YYYY-MM-DD HH:mm" const format="YYYY-MM-DD HH:mm"
class ExerciseReviewAndAnswer extends Component{ class ExerciseReviewAndAnswer extends Component{
@ -86,7 +87,11 @@ class ExerciseReviewAndAnswer extends Component{
// 加载效果 // 加载效果
isSpin:false, isSpin:false,
// 调分数组 // 调分数组
ajustSore:undefined ajustSore:undefined,
//是否是md编辑器
is_md:false,
url: "",
} }
} }
componentDidUpdate (prevProps) { componentDidUpdate (prevProps) {
@ -102,6 +107,18 @@ class ExerciseReviewAndAnswer extends Component{
//window.addEventListener('scroll', this.handleScroll); //window.addEventListener('scroll', this.handleScroll);
} }
handleShowUploadImage = (url) => {
// console.log('==============>>>>>>>>>>>>',url);
// setUrl(url);
this.setState({
url:url
})
}
handleClose=()=>{
this.setState({
url:'',
})
}
remainTime=(time)=>{ remainTime=(time)=>{
// let { time } = this.state; // let { time } = this.state;
@ -206,6 +223,7 @@ class ExerciseReviewAndAnswer extends Component{
data:result.data, data:result.data,
e_ReviewInfo:result.data, e_ReviewInfo:result.data,
exercise:result.data.exercise, exercise:result.data.exercise,
is_md:result.data.exercise.is_md,
exercise_types:result.data.exercise_scores.exercise_types, exercise_types:result.data.exercise_scores.exercise_types,
exercise_scores:result.data.exercise_scores, exercise_scores:result.data.exercise_scores,
exercise_start_at:result.data.exercise_answer_user.start_at, exercise_start_at:result.data.exercise_answer_user.start_at,
@ -633,7 +651,9 @@ class ExerciseReviewAndAnswer extends Component{
Loadtype, Loadtype,
exerciseTotalScore, exerciseTotalScore,
isSpin, isSpin,
ajustSore ajustSore,
is_md,
url
}=this.state }=this.state
let isAdmin = this.props.isAdmin(); let isAdmin = this.props.isAdmin();
let isStudent =this.props.isStudent(); let isStudent =this.props.isStudent();
@ -670,8 +690,15 @@ class ExerciseReviewAndAnswer extends Component{
.standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{ .standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{
width:100%!important width:100%!important
} }
.ql-editor{
padding:0px !important
}
`}</style> `}</style>
{/*<p style={{height:"60px"}}></p>*/} {url?
<QuestionModalPicture {...this.props} {...this.state} handleClose={()=>this.handleClose()}></QuestionModalPicture>
:
""
}
<Modals <Modals
modalsType={Modalstype} modalsType={Modalstype}
modalsTopval={Modalstopval} modalsTopval={Modalstopval}
@ -745,6 +772,10 @@ class ExerciseReviewAndAnswer extends Component{
exercise_types && exercise_types.q_shixuns > 0 && exercise_types && exercise_types.q_shixuns > 0 &&
<span className="color-grey-9 mr15">实训题 {exercise_types.q_shixuns} , {exercise_types && exercise_types.q_shixuns_scores} </span> <span className="color-grey-9 mr15">实训题 {exercise_types.q_shixuns} , {exercise_types && exercise_types.q_shixuns_scores} </span>
} }
{
exercise_types && exercise_types.q_pros > 0 &&
<span className="color-grey-9 mr15">编程题 {exercise_types.q_pros} , {exercise_types && exercise_types.q_pros_scores} </span>
}
<span className="color-grey-3 fr"><span className="color-orange-tip"> {exercise_types &&exercise_types.q_scores} </span></span> <span className="color-grey-3 fr"><span className="color-orange-tip"> {exercise_types &&exercise_types.q_scores} </span></span>
<span className="color-grey-3 fr">合计<span className="color-blue"> {exercise_types &&exercise_types.q_counts} </span></span> <span className="color-grey-3 fr">合计<span className="color-blue"> {exercise_types &&exercise_types.q_counts} </span></span>
</p> </p>
@ -831,6 +862,28 @@ class ExerciseReviewAndAnswer extends Component{
{ {
exercise_questions && exercise_questions.map((item,key)=>{ exercise_questions && exercise_questions.map((item,key)=>{
let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id); let list = ajustSore && ajustSore.filter(obj => obj.id === item.question_id);
let titename="";
if(is_md===true){
console.log(is_md);
titename=(item.question_type == 5 ? item.shixun_name : item.question_title);
}else{
try {
titename = JSON.parse(item.question_title);
}catch (e) {
titename={"ops":[{"insert":item.question_title}]};
}
if(titename===undefined){
titename={"ops":[{"insert":item.question_title}]};
}
try {
// JSON.parse 转换的时候如果是数字字符串就转成整数了
if(titename>=0){
titename={"ops":[{"insert":item.question_title}]};
}
}catch (e) {
}
}
return( return(
<div className="bor-top-greyE pt30 pb30" id={"Anchor_"+parseInt(key+1)}> <div className="bor-top-greyE pt30 pb30" id={"Anchor_"+parseInt(key+1)}>
<p className="clearfix font-16 pl30 pr30"> <p className="clearfix font-16 pl30 pr30">
@ -869,9 +922,19 @@ class ExerciseReviewAndAnswer extends Component{
</p> </p>
<li className="break_word mt15 mb15 pl30 pr30"> <li className="break_word mt15 mb15 pl30 pr30">
{/* <p className="standardAnswer markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML1(item.question_type == 5 ? item.shixun_name : item.question_title).replace(/▁/g,"▁▁▁")}}></p> */} {/* <p className="standardAnswer markdown-body" dangerouslySetInnerHTML={{__html: markdownToHTML1(item.question_type == 5 ? item.shixun_name : item.question_title).replace(/▁/g,"▁▁▁")}}></p> */}
<MarkdownToHtml content={(item.question_type == 5 ? item.shixun_name : item.question_title)} selector={'answer_' + key} {
is_md===true?
<MarkdownToHtml content={titename} selector={'answer_' + key}
className="standardAnswer" className="standardAnswer"
></MarkdownToHtml> ></MarkdownToHtml>
:
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.handleShowUploadImage}
/>
}
</li> </li>
{ {
// 选择题和判断题共用 // 选择题和判断题共用
@ -879,12 +942,14 @@ class ExerciseReviewAndAnswer extends Component{
<Single <Single
{...this.props} {...this.props}
{...this.state} {...this.state}
is_md={is_md}
exercise={exercise} exercise={exercise}
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeOption={(index,ids)=>this.changeOption(index,ids)} changeOption={(index,ids)=>this.changeOption(index,ids)}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key} index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></Single> ></Single>
} }
{ {
@ -893,13 +958,14 @@ class ExerciseReviewAndAnswer extends Component{
<Multiple <Multiple
{...this.props} {...this.props}
{...this.state} {...this.state}
is_md={is_md}
exercise={exercise} exercise={exercise}
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeOption={(index,ids)=>this.changeOption(index,ids)} changeOption={(index,ids)=>this.changeOption(index,ids)}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key} index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></Multiple> ></Multiple>
} }
{ {
@ -910,10 +976,11 @@ class ExerciseReviewAndAnswer extends Component{
{...this.state} {...this.state}
exercise={exercise} exercise={exercise}
questionType={item} questionType={item}
is_md={is_md}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key} index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></FillEmpty> ></FillEmpty>
} }
{ {
@ -922,12 +989,14 @@ class ExerciseReviewAndAnswer extends Component{
<SimpleAnswer <SimpleAnswer
{...this.props} {...this.props}
{...this.state} {...this.state}
is_md={is_md}
exercise={exercise} exercise={exercise}
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)} changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
changeA_flag={(index,status)=>this.changeA_flag(index,status)} changeA_flag={(index,status)=>this.changeA_flag(index,status)}
index={key} index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></SimpleAnswer> ></SimpleAnswer>
} }
{ {
@ -936,12 +1005,13 @@ class ExerciseReviewAndAnswer extends Component{
<ShixunAnswer <ShixunAnswer
{...this.props} {...this.props}
{...this.state} {...this.state}
is_md={is_md}
exercise={exercise} exercise={exercise}
questionType={item} questionType={item}
user_exercise_status={user_exercise_status} user_exercise_status={user_exercise_status}
id={this.state.Id} id={this.state.Id}
index={key} index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></ShixunAnswer> ></ShixunAnswer>
} }

@ -1,6 +1,7 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd"; import {Checkbox,Radio, Input} from "antd";
import {markdownToHTML, MarkdownToHtml} from 'educoder' import {markdownToHTML, MarkdownToHtml} from 'educoder'
import QuillForEditor from "../../../../common/quillForEditor";
import axios from 'axios' import axios from 'axios'
const tagArray = [ const tagArray = [
@ -38,24 +39,65 @@ class Multiple extends Component{
let { let {
questionType , questionType ,
exercise, exercise,
user_exercise_status user_exercise_status,
is_md
}=this.props }=this.props
let isStudent =this.props.isStudent(); let isStudent =this.props.isStudent();
console.log(questionType); console.log(questionType);
return( return(
<div className="pl30 pr30 singleDisplay"> <div className="pl30 pr30 singleDisplay">
<style>
{
`
.multiple .ql-editor p{
line-height: 25px !important;
}
`
}
</style>
<Checkbox.Group className="with100" disabled={ user_exercise_status == 1 ? true : false } onChange={this.saveId} value={questionType.user_answer}> <Checkbox.Group className="with100" disabled={ user_exercise_status == 1 ? true : false } onChange={this.saveId} value={questionType.user_answer}>
{ {
questionType.question_choices && questionType.question_choices.map((item,key)=>{ questionType.question_choices && questionType.question_choices.map((item,key)=>{
let prefix = `${tagArray[key]}.` let prefix = `${tagArray[key]}.`
let titename="";
if(is_md===true){
titename=item.choice_text;
}else{
try {
titename = JSON.parse(item.choice_text);
}catch (e) {
titename={"ops":[{"insert":item.choice_text}]};
}
// JSON.parse 有些异常数据是undefined
if(titename===undefined){
titename={"ops":[{"insert":item.choice_text}]};
}
try {
// JSON.parse 转换的时候如果是数字字符串就转成整数了
if(titename>=0){
titename={"ops":[{"insert":item.choice_text}]};
}
}catch (e) {
}
}
return( return(
<p className="clearfix mb15 df"> <p className="clearfix mb15 df">
<Checkbox className="lineh-15 df mr8 setRadioStyle" value={item.choice_id}> <Checkbox className="lineh-15 df mr8 setRadioStyle multiple" value={item.choice_id}>
<span className="fl mr3 lineh-25">{prefix}</span> <span className="fl mr3 lineh-25">{prefix}</span>
<MarkdownToHtml content={item.choice_text} selector={'multiple_' + (this.props.index + 1) + (key + 1)} {
is_md?
<MarkdownToHtml content={titename} selector={'multiple_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block"}} className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml> ></MarkdownToHtml>
:
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.props.handleShowUploadImage}
/>
}
</Checkbox> </Checkbox>
</p> </p>
) )

@ -1,5 +1,6 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd"; import {Checkbox,Radio, Input} from "antd";
import QuillForEditor from "../../../../common/quillForEditor";
import {markdownToHTML, MarkdownToHtml} from 'educoder' import {markdownToHTML, MarkdownToHtml} from 'educoder'
import axios from 'axios' import axios from 'axios'
@ -33,24 +34,68 @@ class single extends Component{
let { let {
questionType , questionType ,
exercise, exercise,
user_exercise_status user_exercise_status,
is_md
}=this.props }=this.props
let isStudent =this.props.isStudent(); let isStudent =this.props.isStudent();
let isJudge = questionType.question_type == 2 let isJudge = questionType.question_type == 2
return( return(
<div className="pl30 pr30 singleDisplay"> <div className="pl30 pr30 singleDisplay">
<style>
{
`
.single .ql-editor p{
line-height: 25px !important;
}
`
}
</style>
<Radio.Group className="with100" disabled={ user_exercise_status == 1 ? true : false } value={questionType.user_answer[0]} onChange={this.changeItem}> <Radio.Group className="with100" disabled={ user_exercise_status == 1 ? true : false } value={questionType.user_answer[0]} onChange={this.changeItem}>
{ {
questionType.question_choices && questionType.question_choices.map((item,key)=>{ questionType.question_choices && questionType.question_choices.map((item,key)=>{
let prefix = isJudge ? undefined : `${tagArray[key]}.` let prefix = isJudge ? undefined : `${tagArray[key]}.`
let titename="";
if(is_md===true){
titename=item.choice_text;
}else{
try {
titename = JSON.parse(item.choice_text);
}catch (e) {
titename={"ops":[{"insert":item.choice_text}]};
}
// JSON.parse 有些异常数据是undefined
if(titename===undefined){
titename={"ops":[{"insert":item.choice_text}]};
}
try {
// JSON.parse 转换的时候如果是数字字符串就转成整数了
if(titename>=0){
titename={"ops":[{"insert":item.choice_text}]};
}
}catch (e) {
}
}
return( return(
<p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15" : "fl mr40"}> <p className={parseInt(questionType.question_type) == 0 ? "clearfix mb15" : "fl mr40"}>
<Radio className="df lineh-25 setRadioStyle" value={item.choice_id}> <Radio className="df lineh-25 setRadioStyle single" value={item.choice_id}>
<span className="fl mr3 lineh-25">{prefix}</span> <span className="fl mr3 lineh-25">{prefix}</span>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (this.props.index + 1) + (key + 1)} {
is_md?
<MarkdownToHtml content={titename} selector={'single_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block"}} className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml> ></MarkdownToHtml>
:
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.props.handleShowUploadImage}
/>
}
</Radio> </Radio>
</p> </p>
) )

@ -18,7 +18,7 @@ import LoadingSpin from '../../../common/LoadingSpin';
import Contentquestionbank from "./Contentquestionbank"; import Contentquestionbank from "./Contentquestionbank";
import Listjihe from "./Listjihe"; import Listjihe from "./Listjihe";
import Certifiedprofessional from "../../modals/Certifiedprofessional"; import Certifiedprofessional from "../../modals/Certifiedprofessional";
import QuestionModalPicture from '../component/QuestionModalPicture.js' import QuestionModalPicture from '../component/QuestionModalPicture'
const { TabPane } = Tabs; const { TabPane } = Tabs;
const Search = Input.Search; const Search = Input.Search;
class Contentpart extends Component { class Contentpart extends Component {

Loading…
Cancel
Save