Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_hss
杨树林 6 years ago
commit 6c30c8415b

@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base
# 题库的访问权限 # 题库的访问权限
def bank_visit_auth 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? || tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? ||
(current_user.certification_teacher? && @bank.is_public) (current_user.certification_teacher? && @bank.is_public)
end end

@ -35,7 +35,7 @@ class TaskBanksController < ApplicationController
def gtask_bank_params def gtask_bank_params
tip_exception("name参数不能为空") if params[:gtask_bank][:name].blank? tip_exception("name参数不能为空") if params[:gtask_bank][:name].blank?
tip_exception("description参数不能为空") if params[:gtask_bank][:description].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("base_on_project参数不能为空") if params[:gtask_bank][:base_on_project].nil?
tip_exception("min_num参数不能为空") if params[:gtask_bank][:min_num].blank? tip_exception("min_num参数不能为空") if params[:gtask_bank][:min_num].blank?
tip_exception("max_num参数不能为空") if params[:gtask_bank][:max_num].blank? tip_exception("max_num参数不能为空") if params[:gtask_bank][:max_num].blank?

@ -65,7 +65,7 @@ class Users::QuestionBanksController < Users::BaseController
def check_user_permission! def check_user_permission!
if params[:type] == 'publicly' 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 else
render_forbidden unless User.current.admin? || User.current.is_teacher? render_forbidden unless User.current.admin? || User.current.is_teacher?
end end

@ -1,5 +1,6 @@
json.(@bank, :id, :name, :description, :task_type, :is_public) json.(@bank, :id, :name, :description, :task_type, :is_public)
# 附件 # 附件
json.authorize @bank.user_id == current_user.id || current_user.admin?
json.attachments @bank_attachments do |attachment| json.attachments @bank_attachments do |attachment|
json.partial! "attachments/attachment_simple", locals: {attachment: attachment} json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
end end

@ -0,0 +1,5 @@
class GtopicBankIsPublic < ActiveRecord::Migration[5.2]
def change
GtopicBank.where(is_public: nil).update_all(is_public: 0)
end
end

@ -324,7 +324,7 @@ class App extends Component {
title: 'EduCoder', title: 'EduCoder',
desc: '创新源于实践', desc: '创新源于实践',
link: currentUrl, link: currentUrl,
imgUrl: currentUrl + '/images/educoder/index/subject/subject15.jpg' imgUrl: (currentUrl.endsWith('/') ? currentUrl : currentUrl + '/') + 'images/educoder/index/subject/subject15.jpg'
}; };
wx.onMenuShareAppMessage(shareData);//分享给好友 wx.onMenuShareAppMessage(shareData);//分享给好友

@ -1221,7 +1221,7 @@ samp {
} }
/* 毕设任务 */ /* 毕设任务 */
.graduationTaskMenu a{ .graduationTaskMenu>a{
display: block; display: block;
position: relative; position: relative;
line-height: 72px; line-height: 72px;
@ -1229,7 +1229,7 @@ samp {
margin-right: 30px; margin-right: 30px;
float: left; float: left;
} }
.graduationTaskMenu a.active:after{ .graduationTaskMenu>a.active:after{
position: absolute; position: absolute;
left: 0px; left: 0px;
height: 2px; height: 2px;
@ -1239,7 +1239,7 @@ samp {
bottom: 0px; bottom: 0px;
font-weight:400; font-weight:400;
} }
.graduationTaskMenu a.active{ .graduationTaskMenu>a.active{
color: #4CACFF!important; color: #4CACFF!important;
} }

@ -548,7 +548,7 @@ class ExerciseReviewAndAnswer extends Component{
} }
.setRadioStyle .ant-radio,.setRadioStyle .ant-checkbox{ .setRadioStyle .ant-radio,.setRadioStyle .ant-checkbox{
height:16px; height:16px;
margin-top:4px; margin-top:5px;
} }
.standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{ .standardAnswer.editormd-html-preview,.answerStyle.editormd-html-preview{
width:100%!important width:100%!important

@ -49,7 +49,7 @@ class single extends Component{
<Radio className="df lineh-25 setRadioStyle" value={item.choice_id}> <Radio className="df lineh-25 setRadioStyle" value={item.choice_id}>
<span className="fl mr3 lineh-25">{prefix}</span> <span className="fl mr3 lineh-25">{prefix}</span>
<MarkdownToHtml content={item.choice_text} selector={'single_' + (this.props.index + 1) + (key + 1)} <MarkdownToHtml content={item.choice_text} selector={'single_' + (this.props.index + 1) + (key + 1)}
className="flex1" style={{display:"inline-block", 'margin-top': '-1px'}} className="flex1" style={{display:"inline-block"}}
></MarkdownToHtml> ></MarkdownToHtml>
</Radio> </Radio>
</p> </p>

@ -21,11 +21,11 @@ class PollDetailTabThirdInfo extends Component{
<p style={{whiteSpace:"pre-wrap"}} className="color-grey-3 padding20-30">{ pollDetail.poll.polls_description }</p> <p style={{whiteSpace:"pre-wrap"}} className="color-grey-3 padding20-30">{ pollDetail.poll.polls_description }</p>
} }
<p className="padding20-30 clearfix edu-txt-left" style={{background:"#fafafa"}}> <p className="padding20-30 clearfix edu-txt-left" style={{background:"#fafafa"}}>
{ pollDetail && pollDetail.question_types.q_counts===0 ? "" : { !pollDetail || !pollDetail.question_types || pollDetail.question_types.q_counts===0 ? "" :
<span className="color-grey-3"> <span className="color-grey-3">
{ {
pollDetail && pollDetail.question_types.q_counts > 0 && pollDetail && pollDetail.question_types && pollDetail.question_types.q_counts > 0 &&
<span>合计{pollDetail.question_types.q_counts}</span> <span>合计{pollDetail.question_types && pollDetail.question_types.q_counts}</span>
} }
{ {
pollDetail && pollDetail.question_types.q_singles > 0 && pollDetail && pollDetail.question_types.q_singles > 0 &&
@ -44,7 +44,7 @@ class PollDetailTabThirdInfo extends Component{
</p> </p>
{ {
pollDetail && pollDetail.questions.map((item,key)=>{ pollDetail && pollDetail.questions && pollDetail.questions.map((item,key)=>{
return( return(
<div className="previewList"> <div className="previewList">
<p className="pl30 pr30 pt30 pb15 font-16 clearfix"> <p className="pl30 pr30 pt30 pb15 font-16 clearfix">

@ -76,7 +76,7 @@
width: 100%; width: 100%;
} }
.squareCard .squareImg img:hover{ .squareCard .squareImg img:hover{
transform: scale(1.2); transform: scale(1.05);
} }
/* card info */ /* card info */

@ -70,20 +70,22 @@ class InfosTopics extends Component{
// }else{ // }else{
// //
// } // }
this.setState({ this.setState({
isSpin:true isSpin:true
}) })
let types=this.props.match.params.topicstype; let types=this.props.match.params.topicstype;
let user_id=""; 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){ if(user_id===undefined){
console.log(user_id) user_id=this.props.match.params&&this.props.match.params.username;
}
let {per_page}=this.state; let {per_page}=this.state;
let url=`/users/${user_id}/question_banks.json`; let url=`/users/${user_id}/question_banks.json`;
@ -107,7 +109,7 @@ class InfosTopics extends Component{
isSpin:false isSpin:false
}) })
}); });
}
} }
searchCategory=(type)=>{ searchCategory=(type)=>{

@ -78,10 +78,10 @@ class BanksIndex extends Component{
} }
componentDidMount = () =>{ componentDidMount = () =>{
let pathname = this.props.location.pathname; // let pathname = this.props.location.pathname;
this.setState({ // this.setState({
publicly:pathname.indexOf("/publicly") > -1 // publicly:pathname.indexOf("/publicly") > -1
}) // })
} }
@ -92,16 +92,16 @@ class BanksIndex extends Component{
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if(prevProps.current_user!=this.props.current_user){ // if(prevProps.current_user!=this.props.current_user){
let { publicly }=this.state; // let { publicly }=this.state;
if( this.props.checkIfLogin()) { // if( this.props.checkIfLogin()) {
if (this.props.current_user && this.props.current_user.professional_certification == false && publicly){ // if (this.props.current_user && this.props.current_user.professional_certification == false && publicly){
this.props.history.push(`/topicbank/${this.props.current_user.login}/publicly`); // this.props.history.push(`/topicbank/${this.props.current_user.login}/publicly`);
} // }
} else { // } else {
this.props.showLoginDialog() // this.props.showLoginDialog()
} // }
} // }
// let { publicly }=this.state; // let { publicly }=this.state;
// if(this.props.current_user && this.props.current_user.professional_certification == false && publicly){ // if(this.props.current_user && this.props.current_user.professional_certification == false && publicly){
// if( this.props.checkIfLogin()) { // if( this.props.checkIfLogin()) {

@ -59,7 +59,7 @@ class GtaskBanksEdit extends Component {
}); });
} }
toWorkDetail = () => { toWorkDetail = () => {
this.props.history.push(`/banks/gtask/${this.props.match.params.workId}/${this.props.match.params.type}?tab=0`); window.location.href=`/banks/gtask/${this.props.match.params.workId}/${this.props.match.params.type}?tab=0`;
this.props.initPublic(undefined); this.props.initPublic(undefined);
} }
onCancel = () => { onCancel = () => {

@ -18,7 +18,8 @@ class NewGtaskForms extends Component{
initValue = (data) => { initValue = (data) => {
if (data.isEdit) {
if (data.isEdit===true) {
const contentFileList = data.attachments.map(item => { const contentFileList = data.attachments.map(item => {
return { return {
id: item.id, id: item.id,
@ -31,10 +32,10 @@ class NewGtaskForms extends Component{
}) })
this.setState({ this.setState({
...data, ...data,
base_on_project: data.group_info.base_on_project, base_on_project: data.task_type===2?data.group_info.base_on_project:undefined,
title_num: parseInt(data.name.length), title_num: parseInt(data.name.length),
min_num: data.group_info.min_number, min_num: data.task_type===2?data.group_info.min_number:undefined,
max_num: data.group_info.max_number, max_num: data.task_type===2?data.group_info.max_number:undefined,
contentFileList, contentFileList,
}, () => { }, () => {
setTimeout(() => { setTimeout(() => {
@ -47,9 +48,9 @@ class NewGtaskForms extends Component{
}); });
}) })
} else { // new
} }
} }
@ -109,44 +110,41 @@ class NewGtaskForms extends Component{
} }
handleSubmit = () => { handleSubmit = () => {
debugger
let {contentFileList,min_num,max_num,base_on_project}=this.state; let {contentFileList,min_num,max_num,base_on_project}=this.state;
let {data}=this.props; let {data}=this.props;
let task_type=data.task_type let task_type=data.task_type
let topicId=this.props.topicId let topicId=this.props.topicId
this.props.form.validateFieldsAndScroll((err, values) => { this.props.form.validateFields((err, values) => {
const mdContnet = this.contentMdRef.current.getValue().trim(); const mdContnet = this.contentMdRef.current.getValue().trim();
values.description = mdContnet; values.description = mdContnet;
if (!err) { if (!err) {
if (this.state.isEdit) { if (this.props.data.isEdit===true) {
let url="/task_banks/"+topicId+".json"; let url="/task_banks/"+topicId+".json";
axios.put(url, { axios.put(url, {
gtask_bank: { gtask_bank: {
name: values.title, name: values.title,
description: values.description, description: values.description,
min_num:task_type===1?undefined:min_num, min_num:task_type===1?undefined:min_num,
max_num:task_type===1?undefined:max_num, max_num:task_type===1?undefined:max_num,
base_on_project: task_type===1?undefined:base_on_project===true?1:0 base_on_project: task_type===1?undefined:base_on_project===true?1:0
}, },
attachment_ids:contentFileList attachment_ids:contentFileList
} }
).then((response) => { ).then((response) => {
if(response.data.status===0){ if(response.data.status===0){
this.props.showNotification(response.data.message) this.props.showNotification(response.data.message)
}else{ }else{
this.props.showNotification(response.data.message) this.props.showNotification(response.data.message)
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}) })
} else {
} }
} else { } else {
$("html").animate({ scrollTop: $('html').scrollTop() - 100 }) $("html").animate({ scrollTop: $('html').scrollTop() - 100 })
} }
@ -222,7 +220,7 @@ class NewGtaskForms extends Component{
` `
} }
</style> </style>
<Form className="courseForm"> <Form className="courseForm" onClick={this.handleSubmit} >
<div className={"ant-row ant-form-item AboutInputForm newAboutInputForm "}> <div className={"ant-row ant-form-item AboutInputForm newAboutInputForm "}>
<div className="ant-col ant-form-item-label margin0"> <div className="ant-col ant-form-item-label margin0">
<label htmlFor="coursesNew_course" className="ant-form-item-required ">类型</label> <span className={"tasktypes"}>{this.props.data&&this.props.data.task_type===1?"":this.props.data&&this.props.data.task_type===2?"":""}</span> <label htmlFor="coursesNew_course" className="ant-form-item-required ">类型</label> <span className={"tasktypes"}>{this.props.data&&this.props.data.task_type===1?"":this.props.data&&this.props.data.task_type===2?"":""}</span>
@ -342,7 +340,7 @@ class NewGtaskForms extends Component{
<Form.Item> <Form.Item>
<div className="clearfix mt30 mb30"> <div className="clearfix mt30 mb30">
{/* htmlType="submit" */} {/* htmlType="submit" */}
<Button type="primary" onClick={this.handleSubmit} className="defalutSubmitbtn fl mr20">提交</Button> <Button type="primary" htmlType="submit" className="defalutSubmitbtn fl mr20">提交</Button>
<a className="defalutCancelbtn fl" onClick={() => this.props.onCancel()}>取消</ a> <a className="defalutCancelbtn fl" onClick={() => this.props.onCancel()}>取消</ a>
</div> </div>
</Form.Item> </Form.Item>

Loading…
Cancel
Save