|
|
@ -40,8 +40,8 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
componentDidMount() {
|
|
|
|
if(this.props.current_user){
|
|
|
|
if (this.props.current_user) {
|
|
|
|
this.getInfo();
|
|
|
|
this.getInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -107,19 +107,19 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//选中选择题(单选题)选项保存
|
|
|
|
//选中选择题(单选题)选项保存
|
|
|
|
ChangeOptionSingle=(item)=>{
|
|
|
|
ChangeOptionSingle = (item) => {
|
|
|
|
let arr=item.target.name
|
|
|
|
let arr = item.target.name
|
|
|
|
let txt=Object.assign({}, this.state.inputArray[parseInt(arr[1])]);
|
|
|
|
let txt = Object.assign({}, this.state.inputArray[parseInt(arr[1])]);
|
|
|
|
let ids=item.target.value;
|
|
|
|
let ids = item.target.value;
|
|
|
|
let list=txt.answersList.filter(element => element.answer_id == ids);
|
|
|
|
let list = txt.answersList.filter(element => element.answer_id == ids);
|
|
|
|
|
|
|
|
|
|
|
|
this.postAnswer(arr[0],ids,list[0].answer_text=="其他"?txt.text:"",arr[1]);
|
|
|
|
this.postAnswer(arr[0], ids, list[0].answer_text == "其他" ? txt.text : "", arr[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//选中选择题(多选题)选项保存
|
|
|
|
//选中选择题(多选题)选项保存
|
|
|
|
ChangeOptionMuntil=(a_id,q_id,key)=>{
|
|
|
|
ChangeOptionMuntil = (a_id, q_id, key) => {
|
|
|
|
let ind=Object.assign({}, this.state.inputArray[parseInt(key)]);
|
|
|
|
let ind = Object.assign({}, this.state.inputArray[parseInt(key)]);
|
|
|
|
let count=0;
|
|
|
|
let count = 0;
|
|
|
|
a_id.forEach(element => {
|
|
|
|
a_id.forEach(element => {
|
|
|
|
let list = ind.answersList.filter(item => item.answer_id == element);
|
|
|
|
let list = ind.answersList.filter(item => item.answer_id == element);
|
|
|
|
if (list[0].answer_text == "其他") {
|
|
|
|
if (list[0].answer_text == "其他") {
|
|
|
@ -192,11 +192,7 @@ class PollInfo extends Component {
|
|
|
|
//提交主观题
|
|
|
|
//提交主观题
|
|
|
|
commitText = (key, q_id) => {
|
|
|
|
commitText = (key, q_id) => {
|
|
|
|
const text = Object.assign({}, this.state.inputArray[key]).text;
|
|
|
|
const text = Object.assign({}, this.state.inputArray[key]).text;
|
|
|
|
|
|
|
|
|
|
|
|
let url='/poll_questions/'+q_id+'/poll_votes.json?';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let url = '/poll_questions/' + q_id + '/poll_votes.json?';
|
|
|
|
let url = '/poll_questions/' + q_id + '/poll_votes.json?';
|
|
|
|
|
|
|
|
|
|
|
|
const ans = Object.assign({}, this.state.question_answered[key]);
|
|
|
|
const ans = Object.assign({}, this.state.question_answered[key]);
|
|
|
|
ans.ques_status = text ? 1 : 0;
|
|
|
|
ans.ques_status = text ? 1 : 0;
|
|
|
|
const questionAnswered = this.state.question_answered;
|
|
|
|
const questionAnswered = this.state.question_answered;
|
|
|
@ -261,7 +257,7 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cancelSubmit=()=>{
|
|
|
|
cancelSubmit = () => {
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
modalsType: false,
|
|
|
|
modalsType: false,
|
|
|
|
modalsTopval: "",
|
|
|
|
modalsTopval: "",
|
|
|
@ -270,18 +266,18 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sureSubmit=()=>{
|
|
|
|
sureSubmit = () => {
|
|
|
|
let pollId=this.props.match.params.pollId;
|
|
|
|
let pollId = this.props.match.params.pollId;
|
|
|
|
let url=`/polls/${pollId}/commit_poll.json`
|
|
|
|
let url = `/polls/${pollId}/commit_poll.json`
|
|
|
|
axios.post(url).then((result)=>{
|
|
|
|
axios.post(url).then((result) => {
|
|
|
|
if(result.status == 200){
|
|
|
|
if (result.status == 200) {
|
|
|
|
this.props.showNotification(result.data.message)
|
|
|
|
this.props.showNotification(result.data.message)
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
modalsType: false,
|
|
|
|
modalsType: false,
|
|
|
|
modalsTopval: "",
|
|
|
|
modalsTopval: "",
|
|
|
|
modalsBottomval: ""
|
|
|
|
modalsBottomval: ""
|
|
|
|
})
|
|
|
|
})
|
|
|
|
window.location.href=`/classrooms/${this.props.match.params.coursesId}/polls/${pollId}/detail`
|
|
|
|
window.location.href = `/classrooms/${this.props.match.params.coursesId}/polls/${pollId}/detail`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch((error) => {
|
|
|
|
}).catch((error) => {
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
@ -321,13 +317,13 @@ class PollInfo extends Component {
|
|
|
|
<WordsBtn style="grey" className="fl" to={`/classrooms/${this.props.match.params.coursesId}/polls/${poll && poll.left_banner_id}`}>问卷</WordsBtn>
|
|
|
|
<WordsBtn style="grey" className="fl" to={`/classrooms/${this.props.match.params.coursesId}/polls/${poll && poll.left_banner_id}`}>问卷</WordsBtn>
|
|
|
|
<span className="color-grey-9 fl ml3 mr3">></span>
|
|
|
|
<span className="color-grey-9 fl ml3 mr3">></span>
|
|
|
|
<WordsBtn style="grey" to={`/classrooms/${coursesId}/polls/${this.props.match.params.pollId}/detail`} className="fl mr3">问卷详情</WordsBtn>>
|
|
|
|
<WordsBtn style="grey" to={`/classrooms/${coursesId}/polls/${this.props.match.params.pollId}/detail`} className="fl mr3">问卷详情</WordsBtn>>
|
|
|
|
<span className="ml3">{question_types&&question_types.user_name}</span>
|
|
|
|
<span className="ml3">{question_types && question_types.user_name}</span>
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
<p className="clearfix mb20">
|
|
|
|
<p className="clearfix mb20">
|
|
|
|
<span className="color-grey-3 font-24 fl task-hide break-word" style={{ maxWidth: "900px", lineHeight: "30px" }}>{poll && poll.polls_name}</span>
|
|
|
|
<span className="color-grey-3 font-24 fl task-hide break-word" style={{ maxWidth: "900px", lineHeight: "30px" }}>{poll && poll.polls_name}</span>
|
|
|
|
<CoursesListType typelist={[`${statudmap[poll && poll.poll_status]}`]} typesylename={""} />
|
|
|
|
<CoursesListType typelist={[`${statudmap[poll && poll.poll_status]}`]} typesylename={""} />
|
|
|
|
{
|
|
|
|
{
|
|
|
|
isAdmin || (poll && poll.user_poll_status == 1) ? <WordsBtn className="fr font-16 mt5" style="grey" to={`/classrooms/${coursesId}/polls/${this.props.match.params.pollId}/detail`}>返回</WordsBtn> :''
|
|
|
|
isAdmin || (poll && poll.user_poll_status == 1) ? <WordsBtn className="fr font-16 mt5" style="grey" to={`/classrooms/${coursesId}/polls/${this.props.match.params.pollId}/detail`}>返回</WordsBtn> : ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
@ -355,7 +351,7 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<div className={ questionPanelFixed==true ? "questionsfixed":"questionsNo"}>
|
|
|
|
<div className={questionPanelFixed == true ? "questionsfixed" : "questionsNo"}>
|
|
|
|
<p className="clearfix pl20">
|
|
|
|
<p className="clearfix pl20">
|
|
|
|
<span className="mr40 answered">已答</span>
|
|
|
|
<span className="mr40 answered">已答</span>
|
|
|
|
<span className="unanswer">未答</span>
|
|
|
|
<span className="unanswer">未答</span>
|
|
|
@ -383,8 +379,8 @@ class PollInfo extends Component {
|
|
|
|
<div className="previewList" id={'Anchor_' + `${key}`}>
|
|
|
|
<div className="previewList" id={'Anchor_' + `${key}`}>
|
|
|
|
<div className="pl30 pr30 mt30 mb10 clearfix">
|
|
|
|
<div className="pl30 pr30 mt30 mb10 clearfix">
|
|
|
|
<span className="color-blue fl font-16">{item.question.question_number}、{map[item.question.question_type]}</span>
|
|
|
|
<span className="color-blue fl font-16">{item.question.question_number}、{map[item.question.question_type]}</span>
|
|
|
|
{ item.question.is_necessary==1 ? <span className="mustAnswer fl ml10 mr10 mt5">必答</span>:<span className="mustAnswer fl ml10 mr10 mt5">选答</span> }
|
|
|
|
{item.question.is_necessary == 1 ? <span className="mustAnswer fl ml10 mr10 mt5">必答</span> : <span className="mustAnswer fl ml10 mr10 mt5">选答</span>}
|
|
|
|
{ item.question.question_type == 2 && item.question.min_choices && item.question.max_choices ?
|
|
|
|
{item.question.question_type == 2 && item.question.min_choices && item.question.max_choices ?
|
|
|
|
<span className="color-grey-9 font-14 fl mt2">
|
|
|
|
<span className="color-grey-9 font-14 fl mt2">
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.question.min_choices == item.question.max_choices ? "可选" + item.question.max_choices + "项" :
|
|
|
|
item.question.min_choices == item.question.max_choices ? "可选" + item.question.max_choices + "项" :
|
|
|
@ -400,8 +396,8 @@ class PollInfo extends Component {
|
|
|
|
}}>{item.question.question_title}</span></p>
|
|
|
|
}}>{item.question.question_title}</span></p>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//单选
|
|
|
|
//单选
|
|
|
|
item.question.question_type==1 &&
|
|
|
|
item.question.question_type == 1 &&
|
|
|
|
<Radio.Group disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1)?true:false} className="answerList" defaultValue={item.question.poll_answer_ids[0]} name={[item.question.id,key]} onChange={this.ChangeOptionSingle}>
|
|
|
|
<Radio.Group disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1) ? true : false} className="answerList" defaultValue={item.question.poll_answer_ids[0]} name={[item.question.id, key]} onChange={this.ChangeOptionSingle}>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.question.answers && item.question.answers.map((i, k) => {
|
|
|
|
item.question.answers && item.question.answers.map((i, k) => {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -409,17 +405,17 @@ class PollInfo extends Component {
|
|
|
|
<Radio name={[item.question.id, key]} className="fl" value={i.answer_id} ></Radio>
|
|
|
|
<Radio name={[item.question.id, key]} className="fl" value={i.answer_id} ></Radio>
|
|
|
|
<span className="break-word fl" style={{ maxWidth: "1116px" }}>{i.answer_text}</span>
|
|
|
|
<span className="break-word fl" style={{ maxWidth: "1116px" }}>{i.answer_text}</span>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i.answer_text=="其他" ?
|
|
|
|
i.answer_text == "其他" ?
|
|
|
|
<React.Fragment>
|
|
|
|
<React.Fragment>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inputArray && inputArray.map((j,k)=>{
|
|
|
|
inputArray && inputArray.map((j, k) => {
|
|
|
|
return(
|
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
<React.Fragment>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
j.id == item.question.id ?
|
|
|
|
j.id == item.question.id ?
|
|
|
|
<Input type="text" className="otherTxt" autoComplete="off" value={j.text && j.text} name={key}
|
|
|
|
<Input type="text" className="otherTxt" autoComplete="off" value={j.text && j.text} name={key}
|
|
|
|
onInput={this.blurTxt}
|
|
|
|
onInput={this.blurTxt}
|
|
|
|
onBlur={(e)=>this.saveInputAndAnswer(e,i.answer_id,item.question.id,key,item.question.question_type)}
|
|
|
|
onBlur={(e) => this.saveInputAndAnswer(e, i.answer_id, item.question.id, key, item.question.question_type)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
: ""
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -438,10 +434,10 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//多选
|
|
|
|
//多选
|
|
|
|
item.question.question_type==2 &&
|
|
|
|
item.question.question_type == 2 &&
|
|
|
|
<Checkbox.Group
|
|
|
|
<Checkbox.Group
|
|
|
|
onChange={(value)=>this.ChangeOptionMuntil(value,item.question.id,key)}
|
|
|
|
onChange={(value) => this.ChangeOptionMuntil(value, item.question.id, key)}
|
|
|
|
disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1)?true:false}
|
|
|
|
disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1) ? true : false}
|
|
|
|
defaultValue={item.question.poll_answer_ids}
|
|
|
|
defaultValue={item.question.poll_answer_ids}
|
|
|
|
className="answerList"
|
|
|
|
className="answerList"
|
|
|
|
name={key}>
|
|
|
|
name={key}>
|
|
|
@ -452,17 +448,17 @@ class PollInfo extends Component {
|
|
|
|
<Checkbox className="fl mr8" value={i.answer_id} key={i.answer_id}></Checkbox>
|
|
|
|
<Checkbox className="fl mr8" value={i.answer_id} key={i.answer_id}></Checkbox>
|
|
|
|
<span className="break-word fl" style={{ maxWidth: "1116px" }}>{i.answer_text}</span>
|
|
|
|
<span className="break-word fl" style={{ maxWidth: "1116px" }}>{i.answer_text}</span>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i.answer_text=="其他"?
|
|
|
|
i.answer_text == "其他" ?
|
|
|
|
<React.Fragment>
|
|
|
|
<React.Fragment>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inputArray && inputArray.map((j,k)=>{
|
|
|
|
inputArray && inputArray.map((j, k) => {
|
|
|
|
return(
|
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
<React.Fragment>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
j.id == item.question.id ?
|
|
|
|
j.id == item.question.id ?
|
|
|
|
<Input type="text" className="otherTxt" autoComplete="off" value={j.text && j.text} name={key}
|
|
|
|
<Input type="text" className="otherTxt" autoComplete="off" value={j.text && j.text} name={key}
|
|
|
|
onInput={this.blurTxt}
|
|
|
|
onInput={this.blurTxt}
|
|
|
|
onBlur={(e)=>this.saveInputAndAnswer(e,i.answer_id,item.question.id,key,item.question.question_type)}
|
|
|
|
onBlur={(e) => this.saveInputAndAnswer(e, i.answer_id, item.question.id, key, item.question.question_type)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
: ""
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -471,7 +467,7 @@ class PollInfo extends Component {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</React.Fragment>
|
|
|
|
</React.Fragment>
|
|
|
|
:""
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -481,7 +477,7 @@ class PollInfo extends Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//主观题
|
|
|
|
//主观题
|
|
|
|
item.question.question_type==3 &&
|
|
|
|
item.question.question_type == 3 &&
|
|
|
|
<div className="mt10 pl30 pr30 pb20">
|
|
|
|
<div className="mt10 pl30 pr30 pb20">
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inputArray && inputArray.map((j, k) => {
|
|
|
|
inputArray && inputArray.map((j, k) => {
|
|
|
@ -489,7 +485,7 @@ class PollInfo extends Component {
|
|
|
|
<React.Fragment>
|
|
|
|
<React.Fragment>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
j.id == item.question.id ?
|
|
|
|
j.id == item.question.id ?
|
|
|
|
<textarea placeholder="在此填入答案" disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1) ? true:false} value={j.text && j.text} className="winput-100-130" name={key} onInput={this.blurTxt} onBlur={()=>this.commitText(key,item.question.id)}></textarea>
|
|
|
|
<textarea placeholder="在此填入答案" disabled={isAdmin || (isStudent && poll && poll.user_poll_status == 1) ? true : false} value={j.text && j.text} className="winput-100-130" name={key} onInput={this.blurTxt} onBlur={() => this.commitText(key, item.question.id)}></textarea>
|
|
|
|
: ""
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</React.Fragment>
|
|
|
|
</React.Fragment>
|
|
|
@ -510,7 +506,7 @@ class PollInfo extends Component {
|
|
|
|
<div className="mt30 mb50">
|
|
|
|
<div className="mt30 mb50">
|
|
|
|
<a type="primary" className="defalutSubmitbtn" onClick={this.submitPoll}>提交</a>
|
|
|
|
<a type="primary" className="defalutSubmitbtn" onClick={this.submitPoll}>提交</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
:""
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|