Merge branch 'dev_item_bank' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank

dev_jupyter
cxt 5 years ago
commit 79b7c02069

@ -29,7 +29,7 @@ class ApplicationController < ActionController::Base
unless suffix_arr.include?(suffix) unless suffix_arr.include?(suffix)
if params[:client_key].present? if params[:client_key].present?
randomcode = params[:randomcode] randomcode = params[:randomcode]
tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5) # tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}") sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
Rails.logger.info("2222 #{sign}") Rails.logger.info("2222 #{sign}")

@ -94,9 +94,10 @@ export function initAxiosInterceptors(props) {
requestMap[keyName] = false; requestMap[keyName] = false;
} }
axios.interceptors.request.use( axios.interceptors.request.use(
config => { config => {
// config.headers['Content-Type']= 'no-cache'
// if (token) { // 每次发送请求之前判断是否存在token如果存在则统一在http请求的header都加上token不用每次请求都手动添加了 // if (token) { // 每次发送请求之前判断是否存在token如果存在则统一在http请求的header都加上token不用每次请求都手动添加了
// config.headers.Authorization = token; // config.headers.Authorization = token;
// } // }
@ -137,7 +138,7 @@ export function initAxiosInterceptors(props) {
let newopens=md5(opens+timestamp) let newopens=md5(opens+timestamp)
config.url = url; config.url = url;
if (config.url.indexOf('?') == -1) { if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?&randomcode=${timestamp}&client_key=${newopens}`; config.url = `${config.url}?randomcode=${timestamp}&client_key=${newopens}`;
} else { } else {
config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`; config.url = `${config.url}&randomcode=${timestamp}&client_key=${newopens}`;
} }

@ -128,7 +128,7 @@ export function getTaskUrlById(id) {
export function getRandomcode(url) { export function getRandomcode(url) {
Railsgettimes() Railsgettimes()
let anewopens=md5(newopens+newtimestamp); let anewopens=md5(newopens+newtimestamp);
return `${url}?&randomcode=${newtimestamp}&client_key=${anewopens}` return `${url}?randomcode=${newtimestamp}&client_key=${anewopens}`
} }
export function htmlEncode(str) { export function htmlEncode(str) {

@ -1,129 +1,135 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import { import {
Form, Input, InputNumber, Switch, Radio, Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message, Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip Row, Col, Select, Modal, Tooltip
} from 'antd'; } from 'antd';
import axios from 'axios' import axios from 'axios'
import QestionDisplayHeader from './QestionDisplayHeader' import QestionDisplayHeader from './QestionDisplayHeader'
import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder'; import {getUrl, ActionBtn, markdownToHTML, MarkdownToHtml} from 'educoder';
const { TextArea } = Input; const { TextArea } = Input;
const confirm = Modal.confirm; const confirm = Modal.confirm;
const $ = window.$ const $ = window.$
const { Option } = Select; const { Option } = Select;
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
] ]
const qNameArray = [ const qNameArray = [
'单选题', '单选题',
'多选题', '多选题',
'判断题', '判断题',
'填空题', '填空题',
'简答题', '简答题',
'实训题', '实训题',
] ]
class SingleDisplay extends Component{ class SingleDisplay extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state = { this.state = {
question_choices: ['', '', '', ''], question_choices: ['', '', '', ''],
standard_answers: [false, false, false, false] standard_answers: [false, false, false, false]
} }
} }
componentDidMount = () => { componentDidMount = () => {
const Id = this.props.match.params.Id const Id = this.props.match.params.Id
this.isEdit = !!Id this.isEdit = !!Id
if (Id) { if (Id) {
const url = `/exercises/${Id}/edit.json` const url = `/exercises/${Id}/edit.json`
// axios.get(url) // axios.get(url)
// .then((response) => { // .then((response) => {
// if (response.data.status == 0) { // if (response.data.status == 0) {
// } // }
// }) // })
// .catch(function (error) { // .catch(function (error) {
// console.log(error); // console.log(error);
// }); // });
} }
} }
render() { render() {
let { question_title, question_score, question_type, question_choices, standard_answer, let { question_title, question_score, question_type, question_choices, standard_answer,
question_id, question_number, index, displayCount, showActionButton question_id, question_number, index, displayCount, showActionButton
} = this.props; } = this.props;
// const { getFieldDecorator } = this.props.form; // const { getFieldDecorator } = this.props.form;
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId; const courseId=this.props.match.params.coursesId;
const isEdit = this.isEdit const isEdit = this.isEdit
const qNumber = `question_${index}`; const qNumber = `question_${index}`;
// TODO show模式 isNew为false isEdit为false // TODO show模式 isNew为false isEdit为false
// [true, false, true] -> [0, 2] // [true, false, true] -> [0, 2]
// const answerTagArray = standard_answer.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1); // const answerTagArray = standard_answer.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
let length = 5; let length = 5;
const qName = qNameArray[question_type] const qName = qNameArray[question_type]
const isPreviewPage = showActionButton == false const isPreviewPage = showActionButton == false
return( return(
<div className="bor-bottom-greyE padding20-30 singleDisplay" id={qNumber} _id={question_id}> <div className="bor-bottom-greyE padding20-30 singleDisplay" id={qNumber} _id={question_id}>
<style>{` <style>{`
.optionMdEditor { .optionMdEditor {
flex: 0 0 800px flex: 0 0 800px
} }
.optionRow { .optionRow {
margin: 2px; margin: 2px;
} }
.actionBtns { .actionBtns {
height: 28px height: 28px
} }
`}</style> `}</style>
<QestionDisplayHeader {...this.props}></QestionDisplayHeader> <QestionDisplayHeader {...this.props}></QestionDisplayHeader>
{/* 单选 or 多选 */} {/* 单选 or 多选 */}
<div className="options"> <div className="options">
{ question_choices.map((item, optionIndex) => { { question_choices.map((item, optionIndex) => {
let prefix = undefined let prefix = undefined
// if (!isPreviewPage) { // if (!isPreviewPage) {
prefix = `${tagArray[optionIndex]}.` prefix = `${tagArray[optionIndex]}.`
// } // }
if (question_type == 0) { // 单选 if (question_type == 0) { // 单选
return ( return (
<div className="mb10 clearfix" key={optionIndex}> <div className="mb10 clearfix " style={{
<Radio disabled className="fl lineh-25" checked={item.standard_boolean}>{prefix}</Radio> display: "flex",
<MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }} flexDirection:"row",
}} key={optionIndex}>
></MarkdownToHtml> <Radio disabled className="fl lineh-25" checked={item.standard_boolean}>{prefix}</Radio>
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl" <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1) + '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
</div>) ></MarkdownToHtml>
} else { {/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
return ( </div>)
<div className="mb10 clearfix" key={optionIndex}> } else {
<Checkbox disabled className="fl lineh-25 mr8" checked={item.standard_boolean}>{prefix}</Checkbox>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }} return (
<div className="mb10 clearfix" style={{
></MarkdownToHtml> display: "flex",
{/* <span style={{ display: 'inline-block'}} className="markdown-body fl" flexDirection:"row",
dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */} }} key={optionIndex}>
</div>) <Checkbox disabled className="fl lineh-25 mr8" checked={item.standard_boolean}>{prefix}</Checkbox>
} <MarkdownToHtml content={item.choice_text} selector={'single_' + (index + 1)+ '' + (optionIndex + 1)} style={{ float: 'left', display: 'inline-block' }}
})}
></MarkdownToHtml>
</div> {/* <span style={{ display: 'inline-block'}} className="markdown-body fl"
</div> dangerouslySetInnerHTML={{__html: markdownToHTML1(item.choice_text)}}></span> */}
) </div>)
} }
} })}
// RouteHOC()
export default (SingleDisplay); </div>
</div>
)
}
}
// RouteHOC()
export default (SingleDisplay);

@ -112,6 +112,7 @@ class PollDetailTabForth extends Component{
// 已有设置数据的查询 // 已有设置数据的查询
getSettingInfo=()=>{ getSettingInfo=()=>{
this.props.getPollInfo();
let pollId=this.props.match.params.pollId; let pollId=this.props.match.params.pollId;
let url=`/polls/${pollId}/poll_setting.json`; let url=`/polls/${pollId}/poll_setting.json`;
axios.get(url).then((result)=>{ axios.get(url).then((result)=>{
@ -184,7 +185,6 @@ class PollDetailTabForth extends Component{
} }
} }
this.props.getPollInfo();
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
}) })
@ -443,7 +443,7 @@ class PollDetailTabForth extends Component{
}) })
}else{ }else{
this.setState({ this.setState({
flagPageEdit:true flagPageEdit:this.props.isAdmin()?true:false
}) })
} }
} }

@ -343,6 +343,7 @@ class PollDetailTabForthRules extends Component{
render(){ render(){
let {rules,course_group,flagPageEdit}=this.state let {rules,course_group,flagPageEdit}=this.state
let isAdmin=this.props.isAdmin(); let isAdmin=this.props.isAdmin();
console.log(flagPageEdit)
return( return(
<div className="bor-top-greyE pt20"> <div className="bor-top-greyE pt20">
<p className="clearfix mb10"> <p className="clearfix mb10">
@ -477,7 +478,7 @@ class PollDetailTabForthRules extends Component{
</p> </p>
</div> </div>
{ {
flagPageEdit ? flagPageEdit ?this.props.isAdmin()?
<li className="fl pt5"> <li className="fl pt5">
{rule.p_timeflag===undefined?r > 0&&rule.publish_time===null?<Tooltip title="删除"> {rule.p_timeflag===undefined?r > 0&&rule.publish_time===null?<Tooltip title="删除">
<a className="mr20" onClick={()=>this.removeRules(`${r}`)}><i className="iconfont icon-shanchu color-grey-9 font-18"></i></a> <a className="mr20" onClick={()=>this.removeRules(`${r}`)}><i className="iconfont icon-shanchu color-grey-9 font-18"></i></a>
@ -508,7 +509,7 @@ class PollDetailTabForthRules extends Component{
} }
<Tooltip title="新增"><a className="mt6" onClick={this.AddRules}><i className="iconfont icon-tianjiafangda color-green font-18"></i></a> </Tooltip> <Tooltip title="新增"><a className="mt6" onClick={this.AddRules}><i className="iconfont icon-tianjiafangda color-green font-18"></i></a> </Tooltip>
</li> </li>
:"" :"":""
} }
</div> </div>

Loading…
Cancel
Save