|
|
|
@ -4,13 +4,14 @@ import React,{ Component } from "react";
|
|
|
|
|
import Modals from '../../../modals/Modals'
|
|
|
|
|
import { WordsBtn } from 'educoder'
|
|
|
|
|
import HomeworkModal from "../../coursesPublic/HomeworkModal";
|
|
|
|
|
|
|
|
|
|
import OneSelfOrderModal from "../../coursesPublic/OneSelfOrderModal";
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Immediatelypublish extends Component{
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
@ -39,104 +40,170 @@ class Immediatelypublish extends Component{
|
|
|
|
|
}
|
|
|
|
|
//立即发布
|
|
|
|
|
homeworkstart=()=>{
|
|
|
|
|
let {checkBoxValues}=this.props
|
|
|
|
|
let {checkBoxValues,pushtype}=this.props
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(this.props.Exercisetype==="exercise")
|
|
|
|
|
if(pushtype===true){
|
|
|
|
|
if(checkBoxValues.length==0){
|
|
|
|
|
this.props.showNotification("请先在列表中选择数据");
|
|
|
|
|
// this.setState({
|
|
|
|
|
// modalsType:true,
|
|
|
|
|
// modalsTopval:"请先在列表中选择数据",
|
|
|
|
|
// loadtype:true
|
|
|
|
|
// })
|
|
|
|
|
}else{
|
|
|
|
|
let coursesId=this.props.match.params.coursesId;
|
|
|
|
|
if(this.props.Exercisetype==="exercise"){
|
|
|
|
|
let url=`/exercises/${this.props.match.params.Id}/publish_groups.json`;
|
|
|
|
|
axios.get(url).then((response) => {
|
|
|
|
|
if(response.status===200){
|
|
|
|
|
this.setState({
|
|
|
|
|
modalname:"立即发布",
|
|
|
|
|
modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1,
|
|
|
|
|
OneSelftype:true,
|
|
|
|
|
Topval:"学生将立即收到试卷",
|
|
|
|
|
// Botvalleft:"暂不发布",
|
|
|
|
|
Botval:this.props.single ? "":`本操作只对"未发布"的分班有效`,
|
|
|
|
|
starttime:moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
|
|
|
|
|
starttimes:this.props.getNowFormatDates(1),
|
|
|
|
|
endtime:"截止时间:"+this.props.getNowFormatDates(2),
|
|
|
|
|
Cancelname:"暂不发布",
|
|
|
|
|
Savesname:"立即发布",
|
|
|
|
|
Cancel:this.homeworkhide,
|
|
|
|
|
Saves:this.homeworkstartend,
|
|
|
|
|
course_groups:response.data.course_groups,
|
|
|
|
|
starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
let url=`/polls/${this.props.match.params.pollId}/publish_groups.json`;
|
|
|
|
|
axios.get(url).then((response) => {
|
|
|
|
|
if(response){
|
|
|
|
|
|
|
|
|
|
if(checkBoxValues.length==0){
|
|
|
|
|
this.props.showNotification("请先在列表中选择数据");
|
|
|
|
|
// this.setState({
|
|
|
|
|
// modalsType:true,
|
|
|
|
|
// modalsTopval:"请先在列表中选择数据",
|
|
|
|
|
// loadtype:true
|
|
|
|
|
// })
|
|
|
|
|
}else{
|
|
|
|
|
let coursesId=this.props.match.params.coursesId;
|
|
|
|
|
if(this.props.Exercisetype==="exercise"){
|
|
|
|
|
let url=`/courses/${coursesId}/exercises/publish_modal.json`;
|
|
|
|
|
axios.get(url,{
|
|
|
|
|
params:{
|
|
|
|
|
check_ids:checkBoxValues
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
if(response.status===200){
|
|
|
|
|
let list=[];
|
|
|
|
|
if(response.data.course_info){
|
|
|
|
|
for(var i=0;i<response.data.course_info.length;i++){
|
|
|
|
|
list.push({
|
|
|
|
|
id:response.data.course_info[i].course_group_id,
|
|
|
|
|
name:response.data.course_info[i].course_group_name,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
course_groups:list,
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
modalname:"立即发布",
|
|
|
|
|
modaltype:response.data.un_publish > 0 ? 1 : 2,
|
|
|
|
|
visible:true,
|
|
|
|
|
Topval:"学生将立即收到试卷",
|
|
|
|
|
// Botvalleft:"暂不发布",
|
|
|
|
|
Botval:this.props.single ? "":`本操作只对"未发布"的分班有效`,
|
|
|
|
|
starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
|
|
|
|
|
starttimes:this.props.getNowFormatDates(1),
|
|
|
|
|
endtime:"截止时间:"+this.props.getNowFormatDates(2),
|
|
|
|
|
Cancelname:"暂不发布",
|
|
|
|
|
Savesname:"立即发布",
|
|
|
|
|
Cancel:this.homeworkhide,
|
|
|
|
|
Saves:this.homeworkstartend,
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
modalname:"立即发布",
|
|
|
|
|
modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1,
|
|
|
|
|
OneSelftype:true,
|
|
|
|
|
Topval:"学生将立即收到问卷",
|
|
|
|
|
// Botvalleft:"暂不发布",
|
|
|
|
|
Botval:this.props.single ? "":`本操作只对"未发布"的分班有效`,
|
|
|
|
|
starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
|
|
|
|
|
starttimes:this.props.getNowFormatDates(1),
|
|
|
|
|
endtime:"截止时间:"+this.props.getNowFormatDates(2),
|
|
|
|
|
Cancelname:"暂不发布",
|
|
|
|
|
Savesname:"立即发布",
|
|
|
|
|
Cancel:this.homeworkhide,
|
|
|
|
|
Saves:this.homeworkstartend,
|
|
|
|
|
course_groups:response.data.course_groups,
|
|
|
|
|
starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
let url=`/courses/${coursesId}/polls/publish_modal.json`;
|
|
|
|
|
axios.get(url,{
|
|
|
|
|
params:{
|
|
|
|
|
check_ids:checkBoxValues
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
if(response){
|
|
|
|
|
let list=[];
|
|
|
|
|
if(response.data.course_info){
|
|
|
|
|
for(var i=0;i<response.data.course_info.length;i++){
|
|
|
|
|
list.push({
|
|
|
|
|
id:response.data.course_info[i].course_group_id,
|
|
|
|
|
name:response.data.course_info[i].course_group_name,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
course_groups:list,
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
modalname:"立即发布",
|
|
|
|
|
modaltype:response.data.un_publish > 0 ? 1 : 2,
|
|
|
|
|
visible:true,
|
|
|
|
|
Topval:"学生将立即收到问卷",
|
|
|
|
|
// Botvalleft:"暂不发布",
|
|
|
|
|
Botval:this.props.single ? "":`本操作只对"未发布"的分班有效`,
|
|
|
|
|
starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
|
|
|
|
|
starttimes:this.props.getNowFormatDates(1),
|
|
|
|
|
endtime:"截止时间:"+this.props.getNowFormatDates(2),
|
|
|
|
|
Cancelname:"暂不发布",
|
|
|
|
|
Savesname:"立即发布",
|
|
|
|
|
Cancel:this.homeworkhide,
|
|
|
|
|
Saves:this.homeworkstartend,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(checkBoxValues.length==0){
|
|
|
|
|
this.props.showNotification("请先在列表中选择数据");
|
|
|
|
|
// this.setState({
|
|
|
|
|
// modalsType:true,
|
|
|
|
|
// modalsTopval:"请先在列表中选择数据",
|
|
|
|
|
// loadtype:true
|
|
|
|
|
// })
|
|
|
|
|
}else{
|
|
|
|
|
let coursesId=this.props.match.params.coursesId;
|
|
|
|
|
if(this.props.Exercisetype==="exercise"){
|
|
|
|
|
let url=`/courses/${coursesId}/exercises/publish_modal.json`;
|
|
|
|
|
axios.get(url,{
|
|
|
|
|
params:{
|
|
|
|
|
check_ids:checkBoxValues
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
if(response.status===200){
|
|
|
|
|
let list=[];
|
|
|
|
|
if(response.data.course_info){
|
|
|
|
|
for(var i=0;i<response.data.course_info.length;i++){
|
|
|
|
|
list.push({
|
|
|
|
|
id:response.data.course_info[i].course_group_id,
|
|
|
|
|
name:response.data.course_info[i].course_group_name,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
course_groups:list,
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
modalname:"立即发布",
|
|
|
|
|
modaltype:response.data.un_publish > 0 ? 1 : 2,
|
|
|
|
|
visible:true,
|
|
|
|
|
Topval:"学生将立即收到试卷",
|
|
|
|
|
// Botvalleft:"暂不发布",
|
|
|
|
|
Botval:this.props.single ? "":`本操作只对"未发布"的分班有效`,
|
|
|
|
|
starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
|
|
|
|
|
starttimes:this.props.getNowFormatDates(1),
|
|
|
|
|
endtime:"截止时间:"+this.props.getNowFormatDates(2),
|
|
|
|
|
Cancelname:"暂不发布",
|
|
|
|
|
Savesname:"立即发布",
|
|
|
|
|
Cancel:this.homeworkhide,
|
|
|
|
|
Saves:this.homeworkstartend,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
let url=`/courses/${coursesId}/polls/publish_modal.json`;
|
|
|
|
|
axios.get(url,{
|
|
|
|
|
params:{
|
|
|
|
|
check_ids:checkBoxValues
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
if(response){
|
|
|
|
|
let list=[];
|
|
|
|
|
if(response.data.course_info){
|
|
|
|
|
for(var i=0;i<response.data.course_info.length;i++){
|
|
|
|
|
list.push({
|
|
|
|
|
id:response.data.course_info[i].course_group_id,
|
|
|
|
|
name:response.data.course_info[i].course_group_name,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
course_groups:list,
|
|
|
|
|
})
|
|
|
|
|
this.setState({
|
|
|
|
|
modalname:"立即发布",
|
|
|
|
|
modaltype:response.data.un_publish > 0 ? 1 : 2,
|
|
|
|
|
visible:true,
|
|
|
|
|
Topval:"学生将立即收到问卷",
|
|
|
|
|
// Botvalleft:"暂不发布",
|
|
|
|
|
Botval:this.props.single ? "":`本操作只对"未发布"的分班有效`,
|
|
|
|
|
starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
|
|
|
|
|
starttimes:this.props.getNowFormatDates(1),
|
|
|
|
|
endtime:"截止时间:"+this.props.getNowFormatDates(2),
|
|
|
|
|
Cancelname:"暂不发布",
|
|
|
|
|
Savesname:"立即发布",
|
|
|
|
|
Cancel:this.homeworkhide,
|
|
|
|
|
Saves:this.homeworkstartend,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -154,6 +221,7 @@ class Immediatelypublish extends Component{
|
|
|
|
|
modalname:undefined,
|
|
|
|
|
modaltype:undefined,
|
|
|
|
|
visible:false,
|
|
|
|
|
OneSelftype:false,
|
|
|
|
|
Topval:undefined,
|
|
|
|
|
Topvalright:undefined,
|
|
|
|
|
Botvalleft:undefined,
|
|
|
|
@ -174,18 +242,42 @@ class Immediatelypublish extends Component{
|
|
|
|
|
// 确定立即发布
|
|
|
|
|
homeworkstartend=(ids,endtime)=>{
|
|
|
|
|
|
|
|
|
|
let {checkBoxValues}=this.props
|
|
|
|
|
let {checkBoxValues,pushtype}=this.props
|
|
|
|
|
let {chooseId}=this.state;
|
|
|
|
|
let coursesId=this.props.match.params.coursesId;
|
|
|
|
|
|
|
|
|
|
let data={};
|
|
|
|
|
|
|
|
|
|
if(pushtype===true){
|
|
|
|
|
|
|
|
|
|
if(ids.length===0){
|
|
|
|
|
data = {
|
|
|
|
|
check_ids:checkBoxValues,
|
|
|
|
|
end_time: endtime,
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
data={
|
|
|
|
|
check_ids: checkBoxValues,
|
|
|
|
|
group_ids: ids,
|
|
|
|
|
group_end_times:endtime,
|
|
|
|
|
detail:true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
data={
|
|
|
|
|
check_ids:checkBoxValues,
|
|
|
|
|
group_ids:chooseId,
|
|
|
|
|
end_time:endtime
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.props.Exercisetype==="exercise"){
|
|
|
|
|
|
|
|
|
|
let url=`/courses/${coursesId}/exercises/publish.json`
|
|
|
|
|
axios.post(url,{
|
|
|
|
|
check_ids:checkBoxValues,
|
|
|
|
|
group_ids:chooseId,
|
|
|
|
|
end_time:endtime
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
axios.post(url,data).then((result)=>{
|
|
|
|
|
if(result){
|
|
|
|
|
this.props.showNotification(result.data.message);
|
|
|
|
|
this.homeworkhide();
|
|
|
|
@ -210,11 +302,7 @@ class Immediatelypublish extends Component{
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
let url=`/courses/${coursesId}/polls/publish.json`
|
|
|
|
|
axios.post(url,{
|
|
|
|
|
check_ids:checkBoxValues,
|
|
|
|
|
group_ids:chooseId,
|
|
|
|
|
end_time:endtime
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
axios.post(url,data).then((result)=>{
|
|
|
|
|
if(result){
|
|
|
|
|
this.props.showNotification(result.data.message);
|
|
|
|
|
this.homeworkhide();
|
|
|
|
@ -277,6 +365,29 @@ class Immediatelypublish extends Component{
|
|
|
|
|
course_groups={course_groups}
|
|
|
|
|
getcourse_groupslist={(id)=>this.getcourse_groupslist(id)}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/*立即发布*/}
|
|
|
|
|
<OneSelfOrderModal
|
|
|
|
|
modaltype={this.state.modaltype}
|
|
|
|
|
modalname={this.state.modalname}
|
|
|
|
|
OneSelftype={this.state.OneSelftype}
|
|
|
|
|
Topval={this.state.Topval}
|
|
|
|
|
Topvalright={this.state.Topvalright}
|
|
|
|
|
Botvalleft={this.state.Botvalleft}
|
|
|
|
|
Botval={this.state.Botval}
|
|
|
|
|
starttime={this.state.starttime}
|
|
|
|
|
endtime={this.state.endtime}
|
|
|
|
|
Cancelname={this.state.Cancelname}
|
|
|
|
|
Savesname={this.state.Savesname}
|
|
|
|
|
Cancel={this.state.Cancel}
|
|
|
|
|
Saves={this.state.Saves}
|
|
|
|
|
course_groups={this.state.course_groups}
|
|
|
|
|
getcourse_groupslist={(id) => this.getcourse_groupslist(id)}
|
|
|
|
|
starttimes={this.state.starttimes}
|
|
|
|
|
starttimesend={this.state.starttimesend}
|
|
|
|
|
typs={this.state.typs}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* 公用的提示弹框 */}
|
|
|
|
|
<Modals
|
|
|
|
|
modalsType={modalsType}
|
|
|
|
|