diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86d6312ab..a15e2b5ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base # 题库的访问权限 def bank_visit_auth - tip_exception("未通过职业认证") if current_user.is_teacher? && !current_user.certification_teacher? && !current_user.admin? && @bank.user_id != current_user.id && @bank.is_public + tip_exception(-2,"未通过职业认证") if current_user.is_teacher? && !current_user.certification_teacher? && !current_user.admin? && @bank.user_id != current_user.id && @bank.is_public tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? || (current_user.certification_teacher? && @bank.is_public) end diff --git a/app/controllers/exercise_banks_controller.rb b/app/controllers/exercise_banks_controller.rb index 160393e0c..9a35bfcdb 100644 --- a/app/controllers/exercise_banks_controller.rb +++ b/app/controllers/exercise_banks_controller.rb @@ -1,7 +1,7 @@ #encoding: UTF-8 class ExerciseBanksController < ApplicationController before_action :require_login - before_action :find_bank, except: [:choose_shixun] + before_action :find_bank, :bank_visit_auth, except: [:choose_shixun] before_action :bank_admin, only: [:update] before_action :commit_shixun_present, only: [:commit_shixun] diff --git a/app/controllers/gtopic_banks_controller.rb b/app/controllers/gtopic_banks_controller.rb index e0382b21a..f09a8554c 100644 --- a/app/controllers/gtopic_banks_controller.rb +++ b/app/controllers/gtopic_banks_controller.rb @@ -1,6 +1,6 @@ class GtopicBanksController < ApplicationController before_action :require_login - before_action :find_bank + before_action :find_bank, :bank_visit_auth before_action :bank_admin, only: [:edit, :update] def show diff --git a/app/controllers/homework_banks_controller.rb b/app/controllers/homework_banks_controller.rb index 31e733245..61bded033 100644 --- a/app/controllers/homework_banks_controller.rb +++ b/app/controllers/homework_banks_controller.rb @@ -1,6 +1,6 @@ class HomeworkBanksController < ApplicationController before_action :require_login - before_action :find_bank + before_action :find_bank, :bank_visit_auth before_action :bank_params, only: [:update] before_action :bank_admin, only: [:update, :destroy, :set_public] diff --git a/app/controllers/task_banks_controller.rb b/app/controllers/task_banks_controller.rb index 1d3aca955..8d17c15f1 100644 --- a/app/controllers/task_banks_controller.rb +++ b/app/controllers/task_banks_controller.rb @@ -1,6 +1,6 @@ class TaskBanksController < ApplicationController before_action :require_login - before_action :find_bank + before_action :find_bank, :bank_visit_auth before_action :bank_visit_auth before_action :bank_admin, only: [:update] @@ -35,7 +35,7 @@ class TaskBanksController < ApplicationController def gtask_bank_params tip_exception("name参数不能为空") if params[:gtask_bank][:name].blank? tip_exception("description参数不能为空") if params[:gtask_bank][:description].blank? - if @bank.homework_type == 3 + if @bank.task_type == 2 tip_exception("base_on_project参数不能为空") if params[:gtask_bank][:base_on_project].nil? tip_exception("min_num参数不能为空") if params[:gtask_bank][:min_num].blank? tip_exception("max_num参数不能为空") if params[:gtask_bank][:max_num].blank? diff --git a/app/controllers/users/question_banks_controller.rb b/app/controllers/users/question_banks_controller.rb index d6a2fcc88..76523eca4 100644 --- a/app/controllers/users/question_banks_controller.rb +++ b/app/controllers/users/question_banks_controller.rb @@ -65,7 +65,7 @@ class Users::QuestionBanksController < Users::BaseController def check_user_permission! if params[:type] == 'publicly' - render_error("未通过职业认证") unless User.current.admin? || User.current.certification_teacher? + normal_status(-2,"未通过职业认证") unless User.current.admin? || User.current.certification_teacher? else render_forbidden unless User.current.admin? || User.current.is_teacher? end diff --git a/db/migrate/20190906111746_gtopic_bank_is_public.rb b/db/migrate/20190906111746_gtopic_bank_is_public.rb new file mode 100644 index 000000000..193824dc4 --- /dev/null +++ b/db/migrate/20190906111746_gtopic_bank_is_public.rb @@ -0,0 +1,5 @@ +class GtopicBankIsPublic < ActiveRecord::Migration[5.2] + def change + GtopicBank.where(is_public: nil).update_all(is_public: 0) + end +end diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 939d2cdaa..2fbee86da 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -21,16 +21,16 @@ let hashTimeout // TODO 开发期多个身份切换 let debugType ="" -if (isDev) { - const _search = window.location.search; - let parsed = {}; - if (_search) { - parsed = queryString.parse(_search); - } - debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : - window.location.search.indexOf('debug=s') != -1 ? 'student' : - window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' -} +// if (isDev) { +// const _search = window.location.search; +// let parsed = {}; +// if (_search) { +// parsed = queryString.parse(_search); +// } +// debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : +// window.location.search.indexOf('debug=s') != -1 ? 'student' : +// window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' +// } window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/public/react/src/modules/courses/css/Courses.css b/public/react/src/modules/courses/css/Courses.css index 72ea16378..45c7f00af 100644 --- a/public/react/src/modules/courses/css/Courses.css +++ b/public/react/src/modules/courses/css/Courses.css @@ -1221,7 +1221,7 @@ samp { } /* 毕设任务 */ - .graduationTaskMenu a{ + .graduationTaskMenu>a{ display: block; position: relative; line-height: 72px; @@ -1229,7 +1229,7 @@ samp { margin-right: 30px; float: left; } - .graduationTaskMenu a.active:after{ + .graduationTaskMenu>a.active:after{ position: absolute; left: 0px; height: 2px; @@ -1239,7 +1239,7 @@ samp { bottom: 0px; font-weight:400; } - .graduationTaskMenu a.active{ + .graduationTaskMenu>a.active{ color: #4CACFF!important; } diff --git a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js index 0965a19f1..930593c15 100644 --- a/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js +++ b/public/react/src/modules/courses/exercise/ExerciseReviewAndAnswer.js @@ -548,7 +548,7 @@ class ExerciseReviewAndAnswer extends Component{ } .setRadioStyle .ant-radio,.setRadioStyle .ant-checkbox{ height:16px; - margin-top:4px; + margin-top:5px; } .standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{ width:100%!important diff --git a/public/react/src/modules/courses/exercise/question/single.js b/public/react/src/modules/courses/exercise/question/single.js index 5cfd8a902..e739b8f1c 100644 --- a/public/react/src/modules/courses/exercise/question/single.js +++ b/public/react/src/modules/courses/exercise/question/single.js @@ -49,7 +49,7 @@ class single extends Component{ {prefix}

diff --git a/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js b/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js index 792c1b64f..dfe8ad4e7 100644 --- a/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js +++ b/public/react/src/modules/courses/poll/PollDetailTabThirdInfo.js @@ -21,11 +21,11 @@ class PollDetailTabThirdInfo extends Component{

{ pollDetail.poll.polls_description }

}

- { pollDetail && pollDetail.question_types.q_counts===0 ? "" : + { !pollDetail || !pollDetail.question_types || pollDetail.question_types.q_counts===0 ? "" : { - pollDetail && pollDetail.question_types.q_counts > 0 && - 合计{pollDetail.question_types.q_counts}题: + pollDetail && pollDetail.question_types && pollDetail.question_types.q_counts > 0 && + 合计{pollDetail.question_types && pollDetail.question_types.q_counts}题: } { pollDetail && pollDetail.question_types.q_singles > 0 && @@ -44,7 +44,7 @@ class PollDetailTabThirdInfo extends Component{

{ - pollDetail && pollDetail.questions.map((item,key)=>{ + pollDetail && pollDetail.questions && pollDetail.questions.map((item,key)=>{ return(

diff --git a/public/react/src/modules/paths/ShixunPaths.css b/public/react/src/modules/paths/ShixunPaths.css index dc2b21a05..0aab397e7 100644 --- a/public/react/src/modules/paths/ShixunPaths.css +++ b/public/react/src/modules/paths/ShixunPaths.css @@ -76,7 +76,7 @@ width: 100%; } .squareCard .squareImg img:hover{ - transform: scale(1.2); + transform: scale(1.05); } /* card info */ diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js index 8f9c394a5..edd7e554a 100644 --- a/public/react/src/modules/user/usersInfo/InfosTopics.js +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -70,20 +70,22 @@ class InfosTopics extends Component{ // }else{ // // } - this.setState({ - isSpin:true - }) - let types=this.props.match.params.topicstype; - let user_id=""; + this.setState({ + isSpin:true + }) + let types=this.props.match.params.topicstype; + let user_id=""; + + if(types==="publicly"){ + user_id=this.props.current_user&&this.props.current_user.login; + }else{ + user_id=this.props.match.params&&this.props.match.params.username; + } - if(types==="publicly"){ - user_id=this.props.current_user&&this.props.current_user.login; - }else{ - user_id=this.props.match.params&&this.props.match.params.username; - } - if(user_id!=undefined){ - console.log(user_id) + if(user_id===undefined){ + user_id=this.props.match.params&&this.props.match.params.username; + } let {per_page}=this.state; let url=`/users/${user_id}/question_banks.json`; @@ -107,7 +109,7 @@ class InfosTopics extends Component{ isSpin:false }) }); - } + } searchCategory=(type)=>{ diff --git a/public/react/src/modules/user/usersInfo/banks/BanksIndex.js b/public/react/src/modules/user/usersInfo/banks/BanksIndex.js index 15331a2e7..0698048f2 100644 --- a/public/react/src/modules/user/usersInfo/banks/BanksIndex.js +++ b/public/react/src/modules/user/usersInfo/banks/BanksIndex.js @@ -78,10 +78,10 @@ class BanksIndex extends Component{ } componentDidMount = () =>{ - let pathname = this.props.location.pathname; - this.setState({ - publicly:pathname.indexOf("/publicly") > -1 - }) + // let pathname = this.props.location.pathname; + // this.setState({ + // publicly:pathname.indexOf("/publicly") > -1 + // }) } @@ -92,16 +92,16 @@ class BanksIndex extends Component{ } componentDidUpdate(prevProps) { - if(prevProps.current_user!=this.props.current_user){ - let { publicly }=this.state; - if( this.props.checkIfLogin()) { - if (this.props.current_user && this.props.current_user.professional_certification == false && publicly){ - this.props.history.push(`/topicbank/${this.props.current_user.login}/publicly`); - } - } else { - this.props.showLoginDialog() - } - } + // if(prevProps.current_user!=this.props.current_user){ + // let { publicly }=this.state; + // if( this.props.checkIfLogin()) { + // if (this.props.current_user && this.props.current_user.professional_certification == false && publicly){ + // this.props.history.push(`/topicbank/${this.props.current_user.login}/publicly`); + // } + // } else { + // this.props.showLoginDialog() + // } + // } // let { publicly }=this.state; // if(this.props.current_user && this.props.current_user.professional_certification == false && publicly){ // if( this.props.checkIfLogin()) { diff --git a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js index e2c2208da..cfd85b260 100644 --- a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js +++ b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js @@ -18,7 +18,7 @@ class NewGtaskForms extends Component{ initValue = (data) => { - if (data.isEdit) { + const contentFileList = data.attachments.map(item => { return { id: item.id, @@ -47,9 +47,7 @@ class NewGtaskForms extends Component{ }); }) - } else { // new - } } @@ -109,19 +107,19 @@ class NewGtaskForms extends Component{ } handleSubmit = () => { + debugger let {contentFileList,min_num,max_num,base_on_project}=this.state; let {data}=this.props; let task_type=data.task_type let topicId=this.props.topicId - this.props.form.validateFieldsAndScroll((err, values) => { + this.props.form.validateFields((err, values) => { const mdContnet = this.contentMdRef.current.getValue().trim(); values.description = mdContnet; if (!err) { - if (this.state.isEdit) { let url="/task_banks/"+topicId+".json"; axios.put(url, { gtask_bank: { @@ -143,10 +141,6 @@ class NewGtaskForms extends Component{ console.log(error) }) - } else { - - } - } else { $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) } @@ -222,7 +216,7 @@ class NewGtaskForms extends Component{ ` } -

+
{this.props.data&&this.props.data.task_type===1?"普通作业":this.props.data&&this.props.data.task_type===2?"分组作业":""} @@ -342,7 +336,7 @@ class NewGtaskForms extends Component{
{/* htmlType="submit" */} - + this.props.onCancel()}>取消