diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 510044aa4..b3b062c1a 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -116,10 +116,11 @@ class GamesController < ApplicationController @qrcode_str = Base64.encode64( qr.to_img.resize(400,400).to_s ) else - @type = shixun_show_type @game_challenge.show_type #conv = Iconv.new("GBK", "utf-8") @game_challenge = @game.challenge type = @game_challenge.show_type + @type = shixun_show_type type + workspace_path = @game.try(:picture_path) @answer_path = "#{Rails.root}/#{workspace_path}/#{@game_challenge.expect_picture_path}" @user_path = "#{Rails.root}/#{workspace_path}/#{@game_challenge.picture_path}" diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index fa47fd7f6..1d6b15969 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -24,7 +24,7 @@ class MyshixunsController < ApplicationController ActiveRecord::Base.transaction do begin @shixun = Shixun.select(:id, :identifier).find(@myshixun.shixun_id) - @myshixun.destroy + @myshixun.destroy! StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0) diff --git a/app/helpers/games_helper.rb b/app/helpers/games_helper.rb index aff05904f..5a9871673 100644 --- a/app/helpers/games_helper.rb +++ b/app/helpers/games_helper.rb @@ -6,7 +6,7 @@ module GamesHelper end # 获取目录下所有文件,返回一个文件名的数组 type是查看文件的类型image表示图片 - # type [[1, "图片"], [2, "apk/exe"], [3, "txt"], [4, "html"]] + # type [[1, "图片"], [2, "apk/exe"], [3, "txt"], [4, "html"], [5, "mp3"], [6, "mp4"]] def get_dir_filename(path, type, game_id) answer_picture = [] return answer_picture unless File.directory?(path) @@ -39,6 +39,12 @@ module GamesHelper end f.close @type = 'txt' + elsif extension == 'mp3' && type == 5 + answer_picture << file + @type = 'mp3' + elsif extension == 'mp4' && type == 6 + answer_picture << file + @type = 'mp4' end end @@ -51,4 +57,21 @@ module GamesHelper "编译失败,请在测试结果中查看具体的错误信息" : test_set.try(:actual_output) end end + + def shixun_show_type type + case type.to_i + when 1 + "image" + when 2 + "apk/exe" + when 3 + "txt" + when 4 + "html" + when 5 + "mp3" + when 6 + "mp4" + end + end end diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 0bea54eb4..8e4d2ae42 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -1,5 +1,6 @@ class Challenge < ApplicationRecord # difficulty: 关卡难度: 1.简单 2.中等 3.困难 + # show_type: 效果展示:-1.无效果 1.图片 2.apk/exe 3.txt 4.html 5.mp3 6.mp4 default_scope { order("challenges.position asc") } belongs_to :shixun, :touch => true, counter_cache: true diff --git a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js index 440d8893c..deb329fb9 100644 --- a/public/react/src/modules/courses/coursesPublic/HomeworkModal.js +++ b/public/react/src/modules/courses/coursesPublic/HomeworkModal.js @@ -20,6 +20,14 @@ function disabledDateTime() { // disabledSeconds: () => [55, 56], }; } + + +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} + + + class HomeworkModal extends Component{ constructor(props){ super(props); @@ -81,7 +89,7 @@ class HomeworkModal extends Component{ // console.log('startValue',dateString); this.setState({ - endtime: handleDateString(dateString), + endtime: date===null?"":handleDateString(dateString), }) } @@ -188,6 +196,7 @@ class HomeworkModal extends Component{ dropdownClassName="hideDisable" showTime={{ format: 'HH:mm' }} disabledTime={disabledDateTime} + disabledDate={disabledDate} showToday={false} locale={locale} format={dateFormat} diff --git a/public/react/src/modules/courses/coursesPublic/SelectSetting.js b/public/react/src/modules/courses/coursesPublic/SelectSetting.js index 08e01e28e..fa2e014f9 100644 --- a/public/react/src/modules/courses/coursesPublic/SelectSetting.js +++ b/public/react/src/modules/courses/coursesPublic/SelectSetting.js @@ -16,12 +16,17 @@ function range(start, end) { } return result; } + function disabledDateTime() { return { disabledMinutes: () => range(1, 30).concat(range(31, 60)), // disabledSeconds: () => range(1,60) } } + +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} class Selectsetting extends Component{ constructor(props){ super(props); @@ -698,6 +703,7 @@ class Selectsetting extends Component{ onChange={(e,index)=>this.onChangeTimepublishs(e,index,key)} // onChange={ this.onChangeTimepublish } disabledTime={disabledDateTime} + disabledDate={disabledDate} /> {key!=0?this.deletegrouppublish(key)}>:""} @@ -730,7 +736,7 @@ class Selectsetting extends Component{ value={datatime===undefined||datatime===""?"":moment(datatime, dateFormat)} onChange={this.onChangeTimepublish} disabledTime={disabledDateTime} - + disabledDate={disabledDate} />

:""} diff --git a/public/react/src/modules/courses/coursesPublic/sendResource.js b/public/react/src/modules/courses/coursesPublic/sendResource.js index 397711ca3..8443061dd 100644 --- a/public/react/src/modules/courses/coursesPublic/sendResource.js +++ b/public/react/src/modules/courses/coursesPublic/sendResource.js @@ -22,6 +22,11 @@ function disabledDateTime() { }; } +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} + + const dateFormat="YYYY-MM-DD HH:mm"; class Sendresource extends Component{ constructor(props){ @@ -525,6 +530,7 @@ class Sendresource extends Component{ onChange={(e,index)=>this.onChangeTimepublish(e,index,key,2)} // onChange={ this.onChangeTimepublish } disabledTime={disabledDateTime} + disabledDate={disabledDate} /> {key!=0?this.deletegrouppublish(key)}>:""} {key===course_group_publish_times.length-1&&key:""} @@ -551,7 +557,7 @@ class Sendresource extends Component{ value={datatime===undefined||datatime===""?undefined:moment(datatime, dateFormat)} onChange={(e,index)=>this.onChangeTimepublish(e,index,undefined,1)} disabledTime={disabledDateTime} - + disabledDate={disabledDate} />

:""} diff --git a/public/react/src/modules/courses/exercise/Exercisesetting.js b/public/react/src/modules/courses/exercise/Exercisesetting.js index 9b6103fdb..a93aa9942 100644 --- a/public/react/src/modules/courses/exercise/Exercisesetting.js +++ b/public/react/src/modules/courses/exercise/Exercisesetting.js @@ -23,6 +23,7 @@ function range(start, end) { } return result; } + function disabledDateTime() { return { // disabledHours: () => range(0, 24).splice(4, 20), @@ -30,6 +31,11 @@ function disabledDateTime() { // disabledSeconds: () => [0, 60], }; } + +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} + const dataformat="YYYY-MM-DD HH:mm"; class Exercisesetting extends Component{ @@ -636,6 +642,7 @@ class Exercisesetting extends Component{ format="YYYY-MM-DD HH:mm" showToday={false} disabledTime={disabledDateTime} + disabledDate={disabledDate} onChange={this.onChangeTimepublish} value={publish_time && moment(publish_time,"YYYY-MM-DD HH:mm")} disabled={ publish_timetype===true?true:!flagPageEdit } @@ -661,6 +668,7 @@ class Exercisesetting extends Component{ width={"240px"} format="YYYY-MM-DD HH:mm" disabledTime={disabledDateTime} + disabledDate={disabledDate} onChange={this.onChangeTimeEnd} value={end_time && moment(end_time,"YYYY-MM-DD HH:mm")} disabled={ end_timetype===true?true:!flagPageEdit} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js index d6382165b..fc911e024 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js @@ -27,6 +27,11 @@ function disabledDateTime() { }; } +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} + + class GraduationTaskssettingapp extends Component{ constructor(props){ @@ -1181,6 +1186,7 @@ class GraduationTaskssettingapp extends Component{ value={publish_time===null||publish_time===""?"":moment(publish_time, dateFormat)} onChange={this.onChangeTimepublish} disabledTime={disabledDateTime} + disabledDate={disabledDate} disabled={this.props.isAdmin()===true?starttimetype===true?true:flagPageEdit===true?false:true:true} className={ this.state.publishTimetypes===true?"noticeTip":""} /> @@ -1218,6 +1224,7 @@ class GraduationTaskssettingapp extends Component{ value={end_time===null||end_time===""?"":moment(end_time, dateFormat)} onChange={this.onChangeTimeend} disabledTime={disabledDateTime} + disabledDate={disabledDate} // disabled={this.props.isSuperAdmin()===true?flagPageEdit===true?false:true:this.props.isAdmin()===true?endtimetype===true?true:flagPageEdit===true?false:true:true} disabled={this.props.isAdmin()===true?endtimetype===true?true:flagPageEdit===true?false:true:true} className={this.state.endTimetypes===true||end_timetype===true?"noticeTip":""} @@ -1269,6 +1276,7 @@ class GraduationTaskssettingapp extends Component{ width={"210px"} value={latetime===null||latetime===""?"":moment(latetime, dateFormat)} disabledTime={disabledDateTime} + disabledDate={disabledDate} onChange={this.onChangeTimelatetime} disabled={this.props.isAdmin()===true?allowlate===true||allowlate===1?flagPageEdit===true?false:true:true:true} className={ latetimetype===true?"noticeTip":""} @@ -1319,6 +1327,7 @@ class GraduationTaskssettingapp extends Component{ width={"210px"} value={commenttime===null||commenttime=== ""?"":moment(commenttime, dateFormat)} disabledTime={disabledDateTime} + disabledDate={disabledDate} onChange={this.onChangeTimecommenttime} disabled={this.props.isAdmin()===true?flagPageEdit===true?false:true:true} className={ commenttimetype===true?"noticeTip":""} diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index b817136ed..c5602d285 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -28,6 +28,9 @@ function disabledDateTime() { }; } +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} class CoursesNew extends Component { @@ -572,6 +575,7 @@ class CoursesNew extends Component { width={"210px"} value={datatime === undefined ? "" :datatime === null ? "" : moment(datatime, dateFormat)} disabledTime={disabledDateTime} + disabledDate={disabledDate} dropdownClassName="hideDisable" onChange={this.onChangeTimepublishs} /> diff --git a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js index 292830fb8..8b62dd5e4 100644 --- a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js +++ b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js @@ -26,6 +26,12 @@ function disabledDateTime() { // disabledSeconds: () => range(1,60) } } + +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} + + class PollDetailTabForthRules extends Component{ constructor(props){ super(props); @@ -404,6 +410,7 @@ class PollDetailTabForthRules extends Component{ showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm" disabledTime={disabledDateTime} + disabledDate={disabledDate} disabled={ rule.e_timeflag ===undefined?rule.publish_time===null?false:!flagPageEdit:rule.p_timeflag == true ? true : !flagPageEdit} style={{"height":"42px",width:'100%'}} > @@ -429,6 +436,7 @@ class PollDetailTabForthRules extends Component{ showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm" disabledTime={disabledDateTime} + disabledDate={disabledDate} disabled={ rule.e_timeflag ===undefined?rule.publish_time===null?false:!flagPageEdit:rule.e_timeflag == true ? true : !flagPageEdit} style={{"height":"42px"}} > diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 8cbf0402f..ca0fabf4d 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -47,6 +47,9 @@ function disabledDateTime() { } } +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} class Trainingjobsetting extends Component { //unifiedsetting 统一设置 @@ -1766,16 +1769,16 @@ class Trainingjobsetting extends Component { daochushixunbaogao=()=>{ let url =`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`; - this.confirmysl(url + '&export=true'); + this.confirmysl(url, url + '&export=true'); } daochuzuoye =() =>{ let url = `/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`; - this.confirmysl(url + '?export=true'); + this.confirmysl(url, url + '?export=true'); } - confirmysl(url){ - axios.get(url).then((response) => { + confirmysl(url, urlWithExport){ + axios.get(urlWithExport).then((response) => { if(response === undefined){ return } @@ -1935,6 +1938,7 @@ class Trainingjobsetting extends Component { id={"publishtimeid"} disabledDate={this.disabledStartDatestart} disabledTime={disabledDateTime} + disabledDate={disabledDate} className={borreds} showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm" @@ -1967,6 +1971,7 @@ class Trainingjobsetting extends Component { showToday={false} id={"end_timeid"} disabledTime={disabledDateTime} + disabledDate={disabledDate} showTime={{ format: 'HH:mm' }} className={borredss} format="YYYY-MM-DD HH:mm" @@ -2049,6 +2054,7 @@ class Trainingjobsetting extends Component { showToday={false} id={"late_timeid"} disabledTime={disabledDateTime} + disabledDate={disabledDate} format="YYYY-MM-DD HH:mm" value={late_time && moment(late_time, dataformat)} onChange={this.onEndChangeys} diff --git a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js index 2da08e2ad..4ed45790d 100644 --- a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js +++ b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js @@ -339,16 +339,16 @@ class Workquestionandanswer extends Component { daochushixunbaogao=()=>{ let url =`/zip/shixun_report?homework_common_id=${this.props.match.params.homeworkid}`; - this.confirmysl(url + '&export=true'); + this.confirmysl(url, url + '&export=true'); } daochuzuoye =() =>{ let url = `/homework_commons/${this.props.match.params.homeworkid}/works_list.xlsx`; - this.confirmysl(url + '?export=true'); + this.confirmysl(url, url + '?export=true'); } - confirmysl(url){ - axios.get(url).then((response) => { + confirmysl(url, urlWithExport){ + axios.get(urlWithExport).then((response) => { if(response === undefined){ return } diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 8eb2c76dd..bb318ba13 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -199,6 +199,10 @@ function disabledDateTime() { // disabledSeconds: () => [0, 60], }; } + +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} export default class TPMsettings extends Component { constructor(props) { super(props) @@ -1144,7 +1148,7 @@ export default class TPMsettings extends Component { } onChangeTimePicker =(value, dateString)=> { this.setState({ - opening_time:moment(handleDateStrings(dateString)) + opening_time: dateString=== ""?"":moment(handleDateStrings(dateString)) }) } @@ -1871,6 +1875,7 @@ export default class TPMsettings extends Component { width={178} locale={locale} disabledTime={disabledDateTime} + disabledDate={disabledDate} placeholder="请选择开启时间" value={opening_time===null||opening_time===""?"":moment(opening_time, dateFormat)} onChange={this.onChangeTimePicker} diff --git a/public/react/src/modules/tpm/newshixuns/Newshixuns.js b/public/react/src/modules/tpm/newshixuns/Newshixuns.js index f9c8f5b10..790402a22 100644 --- a/public/react/src/modules/tpm/newshixuns/Newshixuns.js +++ b/public/react/src/modules/tpm/newshixuns/Newshixuns.js @@ -191,7 +191,9 @@ function disabledDateTime() { }; } - +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} class Newshixuns extends Component { constructor(props) { super(props) @@ -743,7 +745,7 @@ class Newshixuns extends Component { onChangeTimePicker = (value, dateString) => { this.setState({ - TimePickervalue: moment(handleDateStrings(dateString)) + TimePickervalue: dateString=== ""?"":moment(handleDateStrings(dateString)) }) } @@ -1288,7 +1290,7 @@ class Newshixuns extends Component { placeholder="请选择开启时间" onChange={this.onChangeTimePicker} value={TimePickervalue && moment(TimePickervalue, "YYYY-MM-DD HH:mm")} - + disabledDate={disabledDate} disabledTime={disabledDateTime} dropdownClassName="hideDisable" />