发送题库

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

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

@ -10,12 +10,13 @@ import moment from 'moment';
import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder';
import Modals from '../../modals/Modals';
import CoursesListType from '../coursesPublic/CoursesListType';
import QuillForEditor from "../../../common/quillForEditor";
import Multiple from './question/multiple';
import Single from './question/single';
import FillEmpty from './question/fillEmpty';
import SimpleAnswer from './question/simpleAnswer';
import ShixunAnswer from './question/shixunAnswer';
import QuestionModalPicture from '../../question/component/QuestionModalPicture'
import update from 'immutability-helper';
@ -37,7 +38,7 @@ const tagArray = [
const $ = window.$;
const statudmap={1:"未发布",2:"已发布",3:"已截止"}
const type=["单选题","多选题","判断题","填空题","简答题","实训题"]
const type=["单选题","多选题","判断题","填空题","简答题","实训题","编程题"]
const format="YYYY-MM-DD HH:mm"
class ExerciseReviewAndAnswer extends Component{
@ -86,8 +87,12 @@ class ExerciseReviewAndAnswer extends Component{
// 加载效果
isSpin:false,
// 调分数组
ajustSore:undefined
}
ajustSore:undefined,
//是否是md编辑器
is_md:false,
url: "",
}
}
componentDidUpdate (prevProps) {
// 需要等get_user_info执行完才能getInfo
@ -102,6 +107,18 @@ class ExerciseReviewAndAnswer extends Component{
//window.addEventListener('scroll', this.handleScroll);
}
handleShowUploadImage = (url) => {
// console.log('==============>>>>>>>>>>>>',url);
// setUrl(url);
this.setState({
url:url
})
}
handleClose=()=>{
this.setState({
url:'',
})
}
remainTime=(time)=>{
// let { time } = this.state;
@ -206,6 +223,7 @@ class ExerciseReviewAndAnswer extends Component{
data:result.data,
e_ReviewInfo:result.data,
exercise:result.data.exercise,
is_md:result.data.exercise.is_md,
exercise_types:result.data.exercise_scores.exercise_types,
exercise_scores:result.data.exercise_scores,
exercise_start_at:result.data.exercise_answer_user.start_at,
@ -633,7 +651,9 @@ class ExerciseReviewAndAnswer extends Component{
Loadtype,
exerciseTotalScore,
isSpin,
ajustSore
ajustSore,
is_md,
url
}=this.state
let isAdmin = this.props.isAdmin();
let isStudent =this.props.isStudent();
@ -670,8 +690,15 @@ class ExerciseReviewAndAnswer extends Component{
.standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{
width:100%!important
}
.ql-editor{
padding:0px !important
}
`}</style>
{/*<p style={{height:"60px"}}></p>*/}
{url?
<QuestionModalPicture {...this.props} {...this.state} handleClose={()=>this.handleClose()}></QuestionModalPicture>
:
""
}
<Modals
modalsType={Modalstype}
modalsTopval={Modalstopval}
@ -745,6 +772,10 @@ class ExerciseReviewAndAnswer extends Component{
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>
}
{
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-blue"> {exercise_types &&exercise_types.q_counts} </span></span>
</p>
@ -831,6 +862,28 @@ class ExerciseReviewAndAnswer extends Component{
{
exercise_questions && exercise_questions.map((item,key)=>{
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(
<div className="bor-top-greyE pt30 pb30" id={"Anchor_"+parseInt(key+1)}>
<p className="clearfix font-16 pl30 pr30">
@ -869,9 +922,19 @@ class ExerciseReviewAndAnswer extends Component{
</p>
<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> */}
<MarkdownToHtml content={(item.question_type == 5 ? item.shixun_name : item.question_title)} selector={'answer_' + key}
className="standardAnswer"
></MarkdownToHtml>
{
is_md===true?
<MarkdownToHtml content={titename} selector={'answer_' + key}
className="standardAnswer"
></MarkdownToHtml>
:
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.handleShowUploadImage}
/>
}
</li>
{
// 选择题和判断题共用
@ -879,12 +942,14 @@ class ExerciseReviewAndAnswer extends Component{
<Single
{...this.props}
{...this.state}
is_md={is_md}
exercise={exercise}
questionType={item}
user_exercise_status={user_exercise_status}
changeOption={(index,ids)=>this.changeOption(index,ids)}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></Single>
}
{
@ -893,13 +958,14 @@ class ExerciseReviewAndAnswer extends Component{
<Multiple
{...this.props}
{...this.state}
exercise={exercise}
is_md={is_md}
exercise={exercise}
questionType={item}
user_exercise_status={user_exercise_status}
changeOption={(index,ids)=>this.changeOption(index,ids)}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></Multiple>
}
{
@ -910,10 +976,11 @@ class ExerciseReviewAndAnswer extends Component{
{...this.state}
exercise={exercise}
questionType={item}
user_exercise_status={user_exercise_status}
is_md={is_md}
user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></FillEmpty>
}
{
@ -922,13 +989,15 @@ class ExerciseReviewAndAnswer extends Component{
<SimpleAnswer
{...this.props}
{...this.state}
exercise={exercise}
is_md={is_md}
exercise={exercise}
questionType={item}
user_exercise_status={user_exercise_status}
changeQuestionStatus={(No,flag)=>this.changeQuestionStatus(No,flag)}
changeA_flag={(index,status)=>this.changeA_flag(index,status)}
index={key}
></SimpleAnswer>
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></SimpleAnswer>
}
{
// 实训题
@ -936,12 +1005,13 @@ class ExerciseReviewAndAnswer extends Component{
<ShixunAnswer
{...this.props}
{...this.state}
exercise={exercise}
is_md={is_md}
exercise={exercise}
questionType={item}
user_exercise_status={user_exercise_status}
id={this.state.Id}
index={key}
handleShowUploadImage={(u)=>this.handleShowUploadImage(u)}
></ShixunAnswer>
}

@ -1,6 +1,7 @@
import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd";
import {markdownToHTML, MarkdownToHtml} from 'educoder'
import QuillForEditor from "../../../../common/quillForEditor";
import axios from 'axios'
const tagArray = [
@ -33,29 +34,70 @@ class Multiple extends Component{
console.log(error);
})
}
render(){
let {
questionType ,
let {
questionType ,
exercise,
user_exercise_status
user_exercise_status,
is_md
}=this.props
let isStudent =this.props.isStudent();
console.log(questionType);
return(
<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}>
{
questionType.question_choices && questionType.question_choices.map((item,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(
<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>
<MarkdownToHtml content={item.choice_text} selector={'multiple_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml>
{
is_md?
<MarkdownToHtml content={titename} selector={'multiple_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml>
:
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.props.handleShowUploadImage}
/>
}
</Checkbox>
</p>
)
@ -64,7 +106,7 @@ class Multiple extends Component{
</Checkbox.Group>
{
// 答案公开,且试卷已经截止
isStudent && exercise && exercise.answer_open==true && exercise.exercise_status == 3 &&
isStudent && exercise && exercise.answer_open==true && exercise.exercise_status == 3 &&
<p className="bor-top-greyE pt20 mt10 font-16">参考答案
{questionType.standard_answer.map((i,k)=>{
return(
@ -78,4 +120,4 @@ class Multiple extends Component{
)
}
}
export default Multiple
export default Multiple

@ -1,5 +1,6 @@
import React,{ Component } from "react";
import {Checkbox,Radio, Input} from "antd";
import QuillForEditor from "../../../../common/quillForEditor";
import {markdownToHTML, MarkdownToHtml} from 'educoder'
import axios from 'axios'
@ -30,36 +31,80 @@ class single extends Component{
})
}
render(){
let {
questionType ,
let {
questionType ,
exercise,
user_exercise_status
user_exercise_status,
is_md
}=this.props
let isStudent =this.props.isStudent();
let isJudge = questionType.question_type == 2
return(
<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}>
{
questionType.question_choices && questionType.question_choices.map((item,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(
<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>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml>
{
is_md?
<MarkdownToHtml content={titename} selector={'single_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml>
:
<QuillForEditor
readOnly={true}
value={titename}
showUploadImage={this.props.handleShowUploadImage}
/>
}
</Radio>
</p>
)
})
}
</Radio.Group>
{
{
// 答案公开,且试卷已经截止
isStudent && exercise && exercise.answer_open==true && (exercise.exercise_status == 3 || user_exercise_status == 1) &&
isStudent && exercise && exercise.answer_open==true && (exercise.exercise_status == 3 || user_exercise_status == 1) &&
<p className="bor-top-greyE pt20 mt10 font-16">参考答案
{questionType.standard_answer.map((i,k)=>{
return(
@ -73,4 +118,4 @@ class single extends Component{
)
}
}
export default single
export default single

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

Loading…
Cancel
Save