From 396d4d73f0521c7ec4ba483b4b2794ea58e89107 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 30 Dec 2019 17:35:35 +0800 Subject: [PATCH 01/35] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E6=94=BE=E5=BC=80?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4=E7=9A=84=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/polls_controller.rb | 50 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 0c442a613..2539403af 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -722,19 +722,16 @@ class PollsController < ApplicationController un_anonymous = params[:un_anonymous] ? true : false # 统一设置或者分班为0,则更新问卷,并删除问卷分组 if unified_setting || (course_group_ids.size == 0) - params_publish_time = params[:publish_time].present? ? params[:publish_time].to_time : nil - params_end_time = nil - if params[:end_time].blank? - if params_publish_time.present? - params_end_time = params_publish_time + 30.days - end - else - params_end_time = params[:end_time].to_time - end - # params_end_time = params[:end_time].present? ? params[:end_time].to_time : nil - if poll_status == 2 && @poll.publish_time != params_publish_time - normal_status(-1,"不允许修改发布时间") - elsif poll_status == 3 && (@poll.end_time != params_end_time || @poll.publish_time != params_publish_time) + tip_exception("发布时间不能为空") if params[:publish_time].blank? + tip_exception("截止时间不能为空") if params[:end_time].blank? + tip_exception("截止时间不能早于发布时间") if params[:publish_time].to_time > params[:end_time].to_time + tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day + + params_publish_time = params[:publish_time].to_time + params_end_time = params[:end_time].to_time + + if poll_status != 1 && @poll.publish_time != params_publish_time normal_status(-1,"不允许修改发布时间") elsif params_publish_time.present? && params_end_time.present? && params_end_time < params_publish_time normal_status(-1,"截止时间不能小于发布时间") @@ -761,24 +758,25 @@ class PollsController < ApplicationController total_common_group = poll_groups_ids & total_common #传入的分班与问卷已存在的分班的交集 old_poll_groups = poll_groups_ids - total_common_group #后来传入的分班里,没有了的班级,即需要删除 params_times.each do |t| - course_id = t[:course_group_id] #为数组,可能会设置分班为各个班级id的数组 - poll_publish_time = t[:publish_time].present? ? t[:publish_time].to_time : nil - # poll_end_time = t[:end_time].present? ? t[:end_time].to_time : nil - poll_end_time = nil - if t[:end_time].blank? - if poll_publish_time.present? - poll_end_time = poll_publish_time + 30.days - end - else - poll_end_time = t[:end_time].to_time - end + tip_exception("发布时间不能为空") if t[:publish_time].blank? + tip_exception("截止时间不能为空") if t[:end_time].blank? + tip_exception("截止时间不能早于发布时间") if t[:publish_time].to_time > t[:end_time].to_time + tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")})") if + @course.end_date.present? && t[:end_time].to_time > @course.end_date.end_of_day + + course_id = t[:course_group_id] + poll_publish_time = t[:publish_time].to_time + poll_end_time = t[:end_time].to_time + poll_group = poll_groups.find_in_poll_group("course_group_id",course_id) #判断该分班是否存在 - if poll_group.present? && poll_group.first.end_time <= Time.now && (poll_end_time != poll_group.first.end_time || poll_publish_time != poll_group.first.publish_time) #已截止且时间改变的,则提示错误 + + if poll_group.present? && (poll_group.first.publish_time < Time.now) && (poll_publish_time != poll_group.first.publish_time) error_count += 1 end - if poll_group.present? && poll_group.first.publish_time < Time.now && poll_publish_time != poll_group.first.publish_time + if poll_group.present? && (poll_group.first.publish_time < Time.now && poll_group.first.end_time > Time.now) && (poll_end_time < Time.now) error_count += 1 end + if error_count == 0 common_group = poll_groups_ids & course_id #传入的班级与问卷已存在的班级的交集,即表示已有分班的 new_group_ids = course_id - common_group #新传入的班级id From 85056d3df582971f5136343e1b6b9a7bbcc0d670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Mon, 30 Dec 2019 23:45:18 +0800 Subject: [PATCH 02/35] =?UTF-8?q?=E8=B0=83=E6=95=B4md=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E6=8E=A5=E5=8F=A3+=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/common/UrlTool.js | 45 ++++++- public/react/src/common/educoder.js | 2 +- .../modules/comment/CommentItemMDEditor.js | 4 +- .../CompetitionContentsMd.js | 4 +- .../CompetitionContentspdfdownload.js | 6 +- .../modules/courses/busyWork/NewWorkForm.js | 6 +- .../busyWork/common/TabRightComponents.js | 4 +- .../CompetitionContentsMd.js | 4 +- .../CompetitionContentspdfdownload.js | 6 +- .../courses/coursesPublic/CoursesMarkdown.js | 4 +- .../courses/coursesPublic/SelectSetting.js | 4 +- .../courses/coursesPublic/sendResource.js | 4 +- .../exercise/Testpapersettinghomepage.js | 4 +- .../tasks/GraduationTasksSubmitedit.js | 4 +- .../tasks/GraduationTasksSubmitnew.js | 4 +- .../graduation/tasks/GraduationTasksedit.js | 4 +- .../topics/GraduateTopicPostWorksNew.js | 4 +- .../modules/courses/statistics/Statistics.js | 4 +- .../src/modules/forums/MemoDetailMDEditor.js | 4 +- .../modules/forums/MemoDetailMDEditortwo.js | 4 +- public/react/src/modules/forums/MemoNew.js | 2 +- public/react/src/modules/paths/PathNew.js | 110 ++++-------------- .../src/modules/projectPackages/MDEditors.js | 4 +- .../modules/tpm/TPMsettings/oldTPMsettings.js | 6 +- .../modules/tpm/challengesnew/TPMMDEditor.js | 4 +- .../src/modules/tpm/challengesnew/editorMD.js | 4 +- .../tpm/challengesnew/old/TPManswer.js | 4 +- .../modules/tpm/newshixuns/oldNewshixuns.js | 2 +- .../user/usersInfo/banks/NewGtaskForm.js | 4 +- 29 files changed, 118 insertions(+), 147 deletions(-) diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js index d7a49ea63..e190bdd98 100644 --- a/public/react/src/common/UrlTool.js +++ b/public/react/src/common/UrlTool.js @@ -1,3 +1,4 @@ +import md5 from 'md5'; const isDev = window.location.port == 3007; export const TEST_HOST = "https://test-newweb.educoder.net" export function getImageUrl(path) { @@ -68,19 +69,46 @@ export function getUrl2(path, goTest) { } return `${path ? path: ''}`; } +const newopens ="79e33abd4b6588941ab7622aed1e67e8"; +let newtimestamp; +let checkSubmitFlgs = false; +function railsgettimess(proxy) { + if(checkSubmitFlgs===false){ + $.ajax({url:proxy,async:false,success:function(data){ + if(data.status===0){ + newtimestamp=data.message; + } + }}) + checkSubmitFlgs=true + window.setTimeout(function () { + checkSubmitFlgs=false; + }, 3500); + } +} + +export function Railsgettimes() { + railsgettimess(`${getUrl()}/api/main/first_stamp.json`); +} + export function getUploadActionUrl(path, goTest) { - return `${getUrl()}/api/attachments.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` + Railsgettimes() + let anewopens=md5(newopens+newtimestamp); + return `${getUrl()}/api/attachments.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}`; } export function getUploadActionUrltwo(id) { - - return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` + Railsgettimes() + let anewopens=md5(newopens+newtimestamp); + return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}` } export function getUploadActionUrlthree() { - - return `${getUrlmys()}/api/jupyters/import_with_tpm.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` + Railsgettimes() + let anewopens=md5(newopens+newtimestamp); + return `${getUrlmys()}/api/jupyters/import_with_tpm.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}` } export function getUploadActionUrlOfAuth(id) { - return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` + Railsgettimes() + let anewopens=md5(newopens+newtimestamp); + return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}` } export function test(path) { @@ -96,6 +124,11 @@ export function getTaskUrlById(id) { return `/tasks/${id}` } +export function getRandomcode(url) { + Railsgettimes() + let anewopens=md5(newopens+newtimestamp); + return `${url}?&randomcode=${newtimestamp}&client_key=${anewopens}` +} export function htmlEncode(str) { var s = ""; diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 3d11ee3cb..126a42e87 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -2,7 +2,7 @@ // export { default as OrderStateUtil } from '../routes/Order/components/OrderStateUtil'; -export { getImageUrl as getImageUrl, getUrl as getUrl, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl +export { getImageUrl as getImageUrl, getUrl as getUrl, getRandomcode as getRandomcode,getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl , getUploadActionUrl as getUploadActionUrl,getUploadActionUrltwo as getUploadActionUrltwo ,getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth , getTaskUrlById as getTaskUrlById, TEST_HOST ,htmlEncode as htmlEncode } from './UrlTool'; export { default as queryString } from './UrlTool2'; diff --git a/public/react/src/modules/comment/CommentItemMDEditor.js b/public/react/src/modules/comment/CommentItemMDEditor.js index 8c49d356f..0bde1c6a7 100644 --- a/public/react/src/modules/comment/CommentItemMDEditor.js +++ b/public/react/src/modules/comment/CommentItemMDEditor.js @@ -6,7 +6,7 @@ import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; import PropTypes from 'prop-types'; import classNames from 'classnames' - +import { getImageUrl, toPath, getUrl,getUploadActionUrl } from 'educoder'; import './CommentItemMDEditor.css' const $ = window.$; @@ -36,7 +36,7 @@ class CommentItemMDEditor extends Component { if( $(`#${initMD_ID} textarea`).length === 1 ) { // 没有初始化 const placeholder = '我要回复...' // const imageUrl = `/upload_with_markdown?container_id=${commentId}&container_type=Memo`; - const imageUrl = `/api/attachments.json`; + const imageUrl = `${getUploadActionUrl()}`; const otherOptions = { watch: false, diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js index 049f2bab1..9ea972177 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentsMd.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import {Button, Card, Row, Col ,Upload,Icon,message,Tabs} from 'antd'; import axios from 'axios'; -import {getImageUrl,getUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder'; +import {getUploadActionUrl,getUrl,appendFileSizeToUploadFileAll,appendFileSizeToUploadFile} from 'educoder'; import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; const { TabPane } = Tabs; class CompetitionContentsMd extends Component{ @@ -184,7 +184,7 @@ class CompetitionContentsMd extends Component{ // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, - action: `${getUrl()}/api/attachments.json`, + action: `${getUploadActionUrl()}`, onChange: this.handleContentUploadChange, onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), beforeUpload: (file) => { diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js index eb304e007..360d65937 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommonChild/CompetitionContentspdfChild/CompetitionContentspdfdownload.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import {Button,Layout,Row, Col,Divider,Table} from 'antd'; import axios from 'axios'; -import {getImageUrl} from 'educoder'; +import {getImageUrl,getRandomcode} from 'educoder'; import './CompetitionContentspdfdownload.css'; // import NoneData from "../../../courses/shixunHomework/shixunHomework"; @@ -158,7 +158,7 @@ class CompetitionContentspdfdownload extends Component{ return( - 立即下载 ) @@ -172,7 +172,7 @@ class CompetitionContentspdfdownload extends Component{ return( - 立即下载 ) diff --git a/public/react/src/modules/courses/busyWork/NewWorkForm.js b/public/react/src/modules/courses/busyWork/NewWorkForm.js index 81851d2f2..6740f7579 100644 --- a/public/react/src/modules/courses/busyWork/NewWorkForm.js +++ b/public/react/src/modules/courses/busyWork/NewWorkForm.js @@ -3,7 +3,7 @@ import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Moda import axios from 'axios' import '../css/busyWork.css' import '../css/Courses.css' -import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder' +import {getUploadActionUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder' import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; import CBreadcrumb from '../common/CBreadcrumb' @@ -333,7 +333,7 @@ class NewWorkForm extends Component{ // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, - action: `${getUrl()}/api/attachments.json`, + action: `${getUploadActionUrl()}`, onChange: this.handleContentUploadChange, onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), beforeUpload: (file) => { @@ -352,7 +352,7 @@ class NewWorkForm extends Component{ // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, - action: `${getUrl()}/api/attachments.json`, + action: `${getUploadActionUrl()}`, onChange: this.handleAnswerUploadChange, onRemove: (file) => this.onAttachmentRemove(file, 'answerFileList'), beforeUpload: (file) => { diff --git a/public/react/src/modules/courses/busyWork/common/TabRightComponents.js b/public/react/src/modules/courses/busyWork/common/TabRightComponents.js index 9c8f96cc2..41e03d176 100644 --- a/public/react/src/modules/courses/busyWork/common/TabRightComponents.js +++ b/public/react/src/modules/courses/busyWork/common/TabRightComponents.js @@ -150,8 +150,8 @@ class TabRightComponents extends Component{ {this.props.isAdmin()?