From 42f1bb635378075e412ba5c88e2f5e34216d5e06 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 2 Nov 2019 15:39:19 +0800 Subject: [PATCH 01/34] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a6464a151..e5582ab87 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1116,6 +1116,7 @@ class ExercisesController < ApplicationController # 学生提交试卷 def commit_exercise + tip_exception(-1, "试卷已提交") if @answer_committed_user.commit_status == 1 ActiveRecord::Base.transaction do begin can_commit_exercise = false From 93dffbe1228d8f225d980076d26161d4abcee13a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 4 Nov 2019 13:52:32 +0800 Subject: [PATCH 02/34] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 395d67913..69a8d4ca1 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -502,7 +502,7 @@ module ExercisesHelper exercise_cha_score = 0.0 answer_status = 0 # if game.status == 2 && game.final_score >= 0 - if game.final_score > 0 + if game.final_score > 0 && game.end_time < exercise.end_time exercise_cha_score = game.real_score(exercise_cha.question_score) # exercise_cha_score = exercise_cha.question_score #每一关卡的得分 answer_status = 1 From 9353fc9b7ce982ec0051a59939782e8934d5ff35 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 4 Nov 2019 17:27:57 +0800 Subject: [PATCH 03/34] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=9A=84=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 9 +++ app/mailers/user_mailer.rb | 7 +++ .../user_mailer/course_message_email.html.erb | 62 +++++++++++++++++++ .../user_mailer/course_message_email.text.erb | 1 + ...191104080912_add_email_notify_to_course.rb | 5 ++ 5 files changed, 84 insertions(+) create mode 100644 app/views/user_mailer/course_message_email.html.erb create mode 100644 app/views/user_mailer/course_message_email.text.erb create mode 100644 db/migrate/20191104080912_add_email_notify_to_course.rb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 2302272bf..c1e08d440 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -125,6 +125,9 @@ class MessagesController < ApplicationController @message.message_detail_attributes = {content: params[:content]} @message.save! Attachment.associate_container(params[:attachment_ids], @message.id, @message.class.name) + if @board.course.email_notify && params[:email_notify] + notify_course_students @message, @board.course + end rescue Exception => e uid_logger_error(e.message) tip_exception(e.message) @@ -201,4 +204,10 @@ class MessagesController < ApplicationController def message_params params.require(:message).permit(:subject, :sticky) end + + def notify_course_students message, course + course.students.includes(:user).each do |student| + UserMailer.course_message_email(student&.user&.mail, message.id).deliver_now if student&.user&.mail + end + end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 03ef63bb2..5cd9d787c 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -7,4 +7,11 @@ class UserMailer < ApplicationMailer @code = code mail(to: mail, subject: '验证你的电子邮件') end + + # 课堂讨论区的邮件通知 + def course_message_email(mail, message_id) + @message = Message.find_by(id: message_id) + @course = @message&.board&.course + mail(to: mail, subject: '课堂通知') if @message.present? && @course.present? + end end diff --git a/app/views/user_mailer/course_message_email.html.erb b/app/views/user_mailer/course_message_email.html.erb new file mode 100644 index 000000000..66c75414b --- /dev/null +++ b/app/views/user_mailer/course_message_email.html.erb @@ -0,0 +1,62 @@ + + + + <%= @course.name %>通知 + + + + + +
+
+
+ + + +
+
+
+

+ 您好! +

+

+ 您正在注册Educoder,请在10分钟内在注册页输入此验证码,并进行下一步操作。 + 如非你本人操作,请忽略此邮件。 +

+
+
+

<%= @code %>

+
+ + 此邮件为系统所发,请勿直接回复。
+ 要解决问题或了解您的帐户详情,您可以访问 帮助中心。 +
+
+

+ 如果您并未发过此请求,则可能是因为其他用户在注册时误输了您的邮件地址,而使您收到了这封邮件,那么您可以放心的忽略此邮件,无需进一步采取任何操作。 +

+
+
+ www.educoder.net +
+
+
+ + diff --git a/app/views/user_mailer/course_message_email.text.erb b/app/views/user_mailer/course_message_email.text.erb new file mode 100644 index 000000000..b6fc4c620 --- /dev/null +++ b/app/views/user_mailer/course_message_email.text.erb @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/db/migrate/20191104080912_add_email_notify_to_course.rb b/db/migrate/20191104080912_add_email_notify_to_course.rb new file mode 100644 index 000000000..5a817781c --- /dev/null +++ b/db/migrate/20191104080912_add_email_notify_to_course.rb @@ -0,0 +1,5 @@ +class AddEmailNotifyToCourse < ActiveRecord::Migration[5.2] + def change + add_column :courses, :email_notify, :boolean, default: 0 + end +end From aba3456560d833c4e16c3295b73774e9f15edf65 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 4 Nov 2019 17:31:44 +0800 Subject: [PATCH 04/34] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=9A=84xss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/graduation_topics/_graduation_comments.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/graduation_topics/_graduation_comments.json.jbuilder b/app/views/graduation_topics/_graduation_comments.json.jbuilder index 51551d95d..b9314aa25 100644 --- a/app/views/graduation_topics/_graduation_comments.json.jbuilder +++ b/app/views/graduation_topics/_graduation_comments.json.jbuilder @@ -3,7 +3,7 @@ json.author do end json.id message.id -json.content message.contents_show(identity) +json.content content_safe(message.contents_show(identity)) json.time time_from_now(message.created_at) json.hidden message.hidden # 主贴与子贴不一致 From a52633e9e3af5ea5998caf9a2e92138664448d11 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 4 Nov 2019 21:32:49 +0800 Subject: [PATCH 05/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...91104132649_migrate_2796_exercise_score.rb | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 db/migrate/20191104132649_migrate_2796_exercise_score.rb diff --git a/db/migrate/20191104132649_migrate_2796_exercise_score.rb b/db/migrate/20191104132649_migrate_2796_exercise_score.rb new file mode 100644 index 000000000..375116e94 --- /dev/null +++ b/db/migrate/20191104132649_migrate_2796_exercise_score.rb @@ -0,0 +1,60 @@ +class Migrate2796ExerciseScore < ActiveRecord::Migration[5.2] + def calculate_student_score(exercise,user) + score1 = 0.0 #实训题 + exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers) + exercise_questions.each do |q| + answers_content = q.exercise_answers.where(user_id: user.id) #学生的答案 + if q.question_type <= 2 #为选择题或判断题时 + if answers_content.present? #学生有回答时 + answer_choice_array = [] + answers_content.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + end + user_answer_content = answer_choice_array.sort + standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + + #TODO: 旧版多选题的标准答案是放在一个里面的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + if q.question_type == 1 && standard_answer.size == 1 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort + end + + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + if standard_answer.size > 0 + q_score_1 = q.question_score + # q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 + else + q_score_1 = 0.0 + end + answers_content.update_all(:score => q_score_1) + score1 = score1 + q.question_score + else + answers_content.update_all(:score => -1.0) + score1 += 0.0 + end + else + score1 += 0.0 + end + end + end + score1 + end + + def change + exercise = Exercise.find_by(id: 2796) + if exercise + exercise_users = exercise.exercise_users.where("start_at is not null and commit_status = 0") + exercise_users.each do |exercise_user| + calculate_score = calculate_student_score(exercise, exercise_user.user) + subjective_score = exercise_user.subjective_score + total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score + total_score = calculate_score + total_score_subjective_score + if exercise_user.end_at.nil? + exercise_user.update_attributes!(score:total_score,objective_score:calculate_score,end_at:exercise.end_time,commit_status:1,status:1,commit_method:3) + else + exercise_user.update_attributes!(score:total_score,objective_score:calculate_score) + end + puts exercise_user.id + end + end + end +end From f220ad378e7271d0ae5e1614d708ba3b2aa71381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 5 Nov 2019 14:15:07 +0800 Subject: [PATCH 06/34] =?UTF-8?q?=E8=B0=83=E6=95=B4qq=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/login/Otherloginqq.js | 4 +- .../modules/user/account/AccountBinding.js | 200 ++++++++---------- 2 files changed, 91 insertions(+), 113 deletions(-) diff --git a/public/react/src/modules/login/Otherloginqq.js b/public/react/src/modules/login/Otherloginqq.js index ae614b474..e8e3b73d6 100644 --- a/public/react/src/modules/login/Otherloginqq.js +++ b/public/react/src/modules/login/Otherloginqq.js @@ -9,10 +9,8 @@ class Otherloginqq extends Component { componentDidMount() { let query=this.props.location.search; - if(query!= ""){ - - } const type = query.split('?code='); + const types = type[1].split('&state='); let codeurl = `/auth/qq/callback`; axios.get(codeurl,{params:{ code:type[1], diff --git a/public/react/src/modules/user/account/AccountBinding.js b/public/react/src/modules/user/account/AccountBinding.js index 324aadd93..62c946040 100644 --- a/public/react/src/modules/user/account/AccountBinding.js +++ b/public/react/src/modules/user/account/AccountBinding.js @@ -12,10 +12,29 @@ class AccountSecure extends Component { super(props) this.state = { Modalstype:false, + isphone:false } } - - + IsPC=()=>{ + var userAgentInfo = navigator.userAgent; + var Agents = ["Android", "iPhone", + "SymbianOS", "Windows Phone", + "iPad", "iPod"]; + var flag = true; + for (var v = 0; v < Agents.length; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; + } + componentDidMount() { + let flag = this.IsPC(); //true为PC端,false为手机端 + this.setState({ + isphone: flag + }) + } showModal=()=>{ this.setState({ visible: true, @@ -64,7 +83,13 @@ class AccountSecure extends Component { ModalSave:()=>this.Saveundologin(id), }) } + openqqlogin=()=>{ + window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code` + } + openphoneqqlogin=()=>{ + window.location.href=`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code` + } render() { let {basicInfo}=this.props; @@ -152,120 +177,75 @@ class AccountSecure extends Component {
绑定登录账号
-
-
-
- -
-
-
- - 微信 -
- -
- {basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users.length===0?"":{basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users[0].nickname}} -
+ {/* + en_type: "qq" + id: 60 + nickname: "Sum" + */} + {basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users.length===0?"": + + basicInfo&&basicInfo.open_users.map((item,key)=>{ + + return( +
+
+
+
+ {item.en_type!="qq"?:} + {item.en_type!="qq"?微信:QQ} +
+ +
+ {item.nickname} +
+ +
+ {item.en_type!="qq"? this.showModal("wechat"):() => this.undologin("wechat",item.id) + } + >{item.id===null?"绑定":"解绑"}: this.openphoneqqlogin():this.openqqlogin():() => this.undologin("qq",item.id) + } + >{item.id===null?"绑定":"解绑"}} +
+
+
+
+ ) + }) + } -
- this.showModal("wechat"):() => this.undologin("wechat",basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users[0].id) - } - >{basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users.length===0 ?"绑定":"解绑"} -
- -
-
- - -
- -

- this.handleCancel()}>取消 -

-
-
- - -
- -
-
-
- -
-
-
- - QQ -
- -
- {basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users.length===0?"":{basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users[0].nickname}} -
- -
- this.showModal("wechat"):() => this.undologin("wechat",basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users[0].id) - } - >{basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users.length===0 ?"绑定":"解绑"} -
- -
-
- - -
- -

- this.handleCancel()}>取消 -

-
-
- - + } + + +
+ +

+ this.handleCancel()}>取消 +

- +
* 我们确保你所提供的信息均处于严格保密状态,不会泄露
From e562749e32f8ba63e99f33de0c7e133db3548dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 5 Nov 2019 14:17:55 +0800 Subject: [PATCH 07/34] =?UTF-8?q?=E8=B0=83=E6=95=B4qq=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/login/Otherloginqq.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/login/Otherloginqq.js b/public/react/src/modules/login/Otherloginqq.js index e8e3b73d6..30407bf3c 100644 --- a/public/react/src/modules/login/Otherloginqq.js +++ b/public/react/src/modules/login/Otherloginqq.js @@ -14,7 +14,7 @@ class Otherloginqq extends Component { let codeurl = `/auth/qq/callback`; axios.get(codeurl,{params:{ code:type[1], - redirect_uri:`https://test-newweb.educoder.net/otherloginqq` + redirect_uri:`https://${window.location.host}/otherloginqq` }}).then((result)=> { if(result){ if(result.data.status===0){ From 129c8180ce772203b977b17d98e9e8f054fb8036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 5 Nov 2019 14:50:08 +0800 Subject: [PATCH 08/34] =?UTF-8?q?=E8=B0=83=E6=95=B4qq=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/login/LoginDialog.js | 2 +- .../modules/user/LoginRegisterComponent.js | 2 +- .../modules/user/account/AccountBinding.js | 45 ++++++++++++++----- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/public/react/src/modules/login/LoginDialog.js b/public/react/src/modules/login/LoginDialog.js index 68a01d383..04cfa2e25 100644 --- a/public/react/src/modules/login/LoginDialog.js +++ b/public/react/src/modules/login/LoginDialog.js @@ -539,7 +539,7 @@ class LoginDialog extends Component { } openphoneqqlogin=()=>{ - window.location.href=`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code` + window.open(`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code`) } hideweixinlogin=()=>{ diff --git a/public/react/src/modules/user/LoginRegisterComponent.js b/public/react/src/modules/user/LoginRegisterComponent.js index 3e5731c69..a41c15cc0 100644 --- a/public/react/src/modules/user/LoginRegisterComponent.js +++ b/public/react/src/modules/user/LoginRegisterComponent.js @@ -908,7 +908,7 @@ class LoginRegisterComponent extends Component { } openphoneqqlogin=()=>{ - window.location.href=`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code` + window.open(`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code`) } render() { const { diff --git a/public/react/src/modules/user/account/AccountBinding.js b/public/react/src/modules/user/account/AccountBinding.js index 62c946040..a1ad75d28 100644 --- a/public/react/src/modules/user/account/AccountBinding.js +++ b/public/react/src/modules/user/account/AccountBinding.js @@ -12,7 +12,17 @@ class AccountSecure extends Component { super(props) this.state = { Modalstype:false, - isphone:false + isphone:false, + list:[{ + en_type: "qq", + id: null, + nickname: "", + }, + { + en_type: "wechat", + id: null, + nickname: "", + }] } } IsPC=()=>{ @@ -31,9 +41,30 @@ class AccountSecure extends Component { } componentDidMount() { let flag = this.IsPC(); //true为PC端,false为手机端 + let {basicInfo}=this.props; + let {list}=this.state; this.setState({ isphone: flag }) + let newlist=list; + + if(basicInfo===undefined||JSON.stringify(basicInfo) == "{}"||basicInfo&&basicInfo.open_users.length===0){ + + }else{ + basicInfo&&basicInfo.open_users.map((item,key)=>{ + newlist.map((items,keys)=>{ + if(item.en_type===items.en_type){ + items.id=item.id; + items.nickname=item.nickname; + } + }) + }) + } + + this.setState({ + list:newlist + }) + } showModal=()=>{ this.setState({ @@ -88,11 +119,11 @@ class AccountSecure extends Component { } openphoneqqlogin=()=>{ - window.location.href=`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code` + window.open(`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code`) } render() { let {basicInfo}=this.props; - + let {list}=this.state; return (
@@ -177,14 +208,8 @@ class AccountSecure extends Component {
绑定登录账号
- {/* - en_type: "qq" - id: 60 - nickname: "Sum" - */} - {basicInfo===undefined||JSON.stringify(basicInfo) == "{}"?"":basicInfo&&basicInfo.open_users.length===0?"": - basicInfo&&basicInfo.open_users.map((item,key)=>{ + {list.map((item,key)=>{ return(
From e796cd688214d38b94f50391b698e0aa03db4329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 5 Nov 2019 14:51:41 +0800 Subject: [PATCH 09/34] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/user/account/AccountBinding.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/user/account/AccountBinding.js b/public/react/src/modules/user/account/AccountBinding.js index a1ad75d28..eb62aa1e1 100644 --- a/public/react/src/modules/user/account/AccountBinding.js +++ b/public/react/src/modules/user/account/AccountBinding.js @@ -14,15 +14,15 @@ class AccountSecure extends Component { Modalstype:false, isphone:false, list:[{ + en_type: "wechat", + id: null, + nickname: "", + },{ en_type: "qq", id: null, nickname: "", - }, - { - en_type: "wechat", - id: null, - nickname: "", - }] + } + ] } } IsPC=()=>{ @@ -231,7 +231,7 @@ class AccountSecure extends Component { } >{item.id===null?"绑定":"解绑"}: this.openphoneqqlogin():this.openqqlogin():() => this.undologin("qq",item.id) + item.id===null?this.state.isphone===true?() => this.openphoneqqlogin():() => this.openqqlogin():() => this.undologin("qq",item.id) } >{item.id===null?"绑定":"解绑"}}
From de89189641a42e6c500d1cbf7c2aee80443c1e1e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 5 Nov 2019 14:56:44 +0800 Subject: [PATCH 10/34] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E6=88=AA=E6=AD=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_answers_controller.rb | 2 +- app/controllers/exercises_controller.rb | 4 +- app/helpers/exercises_helper.rb | 7 +- app/jobs/end_exercise_calculate_job.rb | 4 +- app/models/exercise.rb | 2 +- app/tasks/exercise_publish_task.rb | 102 ++++++++---------- lib/tasks/poll_publish.rake | 2 +- 7 files changed, 57 insertions(+), 66 deletions(-) diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index b1e23071b..4b94676e5 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -107,7 +107,7 @@ class ExerciseAnswersController < ApplicationController normal_status(-1,"已提交/已结束的试卷不允许修改!") else if (@exercise_user_status == Exercise::DEADLINE && @exercise_user.commit_status == 0) || (@exercise.time > 0 && @exercise_user.start_at.present? && ((@exercise_user.start_at + @exercise.time.to_i.minutes) < Time.now)) - objective_score = calculate_student_score(@exercise,current_user)[:total_score] + objective_score = calculate_student_score(@exercise,current_user,Time.now)[:total_score] subjective_score = @exercise_user.subjective_score < 0.0 ? 0.0 : @exercise_user.subjective_score total_score = objective_score + subjective_score commit_option = { diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 3b4d65a1f..97e0593d8 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -886,7 +886,7 @@ class ExercisesController < ApplicationController ex_user_ids = exercise_users.pluck(:id) - EndExerciseCalculateJob.perform_later(ex_user_ids,exercise) + EndExerciseCalculateJob.perform_later(ex_user_ids,exercise,Time.now) # exercise_users.each do |user| # if user.commit_status == 0 && user.start_at.present? # objective_score = calculate_student_score(exercise,user.user)[:total_score] @@ -1141,7 +1141,7 @@ class ExercisesController < ApplicationController can_commit_exercise = true end if can_commit_exercise - objective_score = calculate_student_score(@exercise,current_user)[:total_score] + objective_score = calculate_student_score(@exercise,current_user,Time.now)[:total_score] subjective_score = @answer_committed_user.subjective_score total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score total_score = objective_score + total_score_subjective_score diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 41d2a748e..44c341d6e 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -412,12 +412,13 @@ module ExercisesHelper end #计算试卷的总分和试卷的答题状态 - def calculate_student_score(exercise,user) + def calculate_student_score(exercise,user,end_time) score1 = 0.0 #选择题/判断题 score2 = 0.0 #填空题 score5 = 0.0 #实训题 ques_stand = [] #问题是否正确 - exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers,:exercise_shixun_challenges) + exercise_end_time = end_time || Time.now + exercise_questions = exercise.exercise_questions.includes(:exercise_standard_answers,:exercise_shixun_challenges) exercise_questions&.each do |q| begin if q.question_type != 5 @@ -505,7 +506,7 @@ module ExercisesHelper exercise_cha_score = 0.0 answer_status = 0 # if game.status == 2 && game.final_score >= 0 - if game.final_score > 0 && game.end_time < exercise.end_time + if game.final_score > 0 && game.end_time && game.end_time < exercise_end_time exercise_cha_score = game.real_score(exercise_cha.question_score) # exercise_cha_score = exercise_cha.question_score #每一关卡的得分 answer_status = 1 diff --git a/app/jobs/end_exercise_calculate_job.rb b/app/jobs/end_exercise_calculate_job.rb index b6d8e491e..35c6ded57 100644 --- a/app/jobs/end_exercise_calculate_job.rb +++ b/app/jobs/end_exercise_calculate_job.rb @@ -5,11 +5,11 @@ class EndExerciseCalculateJob < ApplicationJob queue_as :default - def perform(ex_user_ids,exercise) + def perform(ex_user_ids,exercise,end_time) exercise_users = ExerciseUser.where(id: ex_user_ids) exercise_users.each do |user| if user.commit_status == 0 && user.start_at.present? - objective_score = calculate_student_score(exercise,user.user)[:total_score] + objective_score = calculate_student_score(exercise,user.user,end_time)[:total_score] user_sub_score = user.subjective_score subjective_score = user_sub_score < 0.0 ? 0.0 : user_sub_score total_score = objective_score + subjective_score diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 0b9963eee..177c0ac88 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -70,7 +70,7 @@ class Exercise < ApplicationRecord if unified_setting self&.end_time else - user_course_group = course.course_members.find_by(user_id: user_id)&.course_group_id + user_course_group = course.students.find_by(user_id: user_id)&.course_group_id exercise_group_settings.find_by(course_group_id:user_course_group)&.end_time end end diff --git a/app/tasks/exercise_publish_task.rb b/app/tasks/exercise_publish_task.rb index 04e37d126..6aa444683 100644 --- a/app/tasks/exercise_publish_task.rb +++ b/app/tasks/exercise_publish_task.rb @@ -41,20 +41,21 @@ class ExercisePublishTask puts "--------------------------------exercise_publish end" end + def end Rails.logger.info("log--------------------------------exercise_end start") puts "--------------------------------exercise_end start" # 1。统一设置的试卷 - exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND - unified_setting = true AND end_time <= ?",Time.now + 900) - exercises&.each do |exercise| - ex_type = exercise.exercise_questions.pluck(:question_type).uniq + exercises = Exercise.includes(:exercise_questions).where("exercise_status = 2 AND end_time <= ?",Time.now + 900) + exercises.each do |exercise| + Rails.logger.info("end_exercise_id: #{exercise.id}") exercise.update_column('exercise_status', 3) - exercise.exercise_users&.each do |exercise_user| - begin - Rails.logger.info("true: user_id:#{exercise_user.user_id}--commit_status:#{exercise_user.commit_status}") - if (exercise_user&.commit_status == 0) && (exercise_user&.start_at.present?) - s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] + if exercise.unified_setting + ex_type = exercise.exercise_questions.pluck(:question_type).uniq + exercise.exercise_users.where("commit_status = 0 and start_at is not null").each do |exercise_user| + begin + Rails.logger.info("true: user_id:#{exercise_user.user_id}--commit_status:#{exercise_user.commit_status}") + s_score = calculate_student_score(exercise, exercise_user.user, exercise.end_time)[:total_score] if ex_type.include?(4) #是否包含主观题 subjective_score = exercise_user.subjective_score else @@ -66,72 +67,61 @@ class ExercisePublishTask Rails.logger.info("true: user_id:#{exercise_user.user_id}--s_score:#{s_score}") Rails.logger.info("true: user_id:#{exercise_user.user_id}--commit_method:#{exercise_user.commit_method}") commit_option = { - :status => 1, - :commit_status => 1, - :end_at => Time.now, - :objective_score => s_score, - :score => total_score, - :subjective_score => subjective_score, - :commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3 + :status => 1, + :commit_status => 1, + :end_at => exercise.end_time, + :objective_score => s_score, + :score => total_score, + :subjective_score => subjective_score, + :commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3 } exercise_user.update_attributes(commit_option) + rescue Exception => e + Rails.logger.info("rescue errors ___________________________#{e}") + next end - rescue Exception => e - Rails.logger.info("rescue errors ___________________________#{e}") - next end - end end - # 2.非统一的试卷 - all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900) - exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")" - ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}") - ex_group_settings&.each do |exercise_setting| + ExerciseGroupSetting.where("end_time < ? and end_time > ?", Time.now + 900, Time.now - 900).each do |exercise_setting| exercise = exercise_setting.exercise - if exercise.end_time <= Time.now - exercise.update_column('exercise_status', 3) - end + Rails.logger.info("exercise_group_setting: exercise_id:#{exercise.id}--group_settings_id:#{exercise_setting.id}") + users = exercise.course.course_members.where(:course_group_id => exercise_setting.course_group_id) + exercise_users = exercise.exercise_users.where(user_id: users.pluck(:user_id)).where("commit_status = 0 and start_at is not null") ex_types = exercise.exercise_questions.pluck(:question_type).uniq - users = exercise.course.students.where(:course_group_id => exercise_setting.course_group_id) - exercise_users = exercise.exercise_users.where(:user_id => users.pluck(:user_id)) - exercise_users&.each do |exercise_user| + exercise_users.each do |exercise_user| + Rails.logger.info("false: user_id:#{exercise_user.user_id}--commit_status:#{exercise_user.commit_status}") begin - Rails.logger.info("false: user_id:#{exercise_user.user_id}--commit_status:#{exercise_user.commit_status}") - if exercise_user.commit_status == 0 && !exercise_user.start_at.nil? - if ex_types.include?(4) #是否包含主观题 - subjective_score = exercise_user.subjective_score - else - subjective_score = -1.0 - end - s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] - total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score - total_score = s_score + total_score_subjective_score - Rails.logger.info("false: user_id:#{exercise_user.user_id}--s_score:#{s_score}") - Rails.logger.info("false: user_id:#{exercise_user.user_id}--subjective_score:#{subjective_score}") - Rails.logger.info("false: user_id:#{exercise_user.user_id}--commit_method:#{exercise_user.commit_method}") - commit_option = { - :status => 1, - :commit_status => 1, - :end_at => Time.now, - :objective_score => s_score, - :score => total_score, - :subjective_score => subjective_score, - :commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3 - } - exercise_user.update_attributes(commit_option) + if ex_types.include?(4) #是否包含主观题 + subjective_score = exercise_user.subjective_score + else + subjective_score = -1.0 end + s_score = calculate_student_score(exercise, exercise_user.user, exercise_setting.end_time)[:total_score] + total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score + total_score = s_score + total_score_subjective_score + Rails.logger.info("false: user_id:#{exercise_user.user_id}--s_score:#{s_score}") + Rails.logger.info("false: user_id:#{exercise_user.user_id}--subjective_score:#{subjective_score}") + Rails.logger.info("false: user_id:#{exercise_user.user_id}--commit_method:#{exercise_user.commit_method}") + commit_option = { + :status => 1, + :commit_status => 1, + :end_at => exercise_setting.end_time, + :objective_score => s_score, + :score => total_score, + :subjective_score => subjective_score, + :commit_method => exercise_user&.commit_method.to_i > 0 ? exercise_user&.commit_method.to_i : 3 + } + exercise_user.update_attributes(commit_option) rescue Exception => e Rails.logger.info("unified_setting_false_rescue errors ___________________________#{e}") next end - end end Rails.logger.info("log--------------------------------exercise_end end") puts "--------------------------------exercise_end end" end - end \ No newline at end of file diff --git a/lib/tasks/poll_publish.rake b/lib/tasks/poll_publish.rake index 2460e88c9..1b6d63bcc 100644 --- a/lib/tasks/poll_publish.rake +++ b/lib/tasks/poll_publish.rake @@ -110,7 +110,7 @@ namespace :poll_publish do # # end # end - PollGroupSetting.where("end_time < ? and end_time > ?", Time.now + 1800, Time.now - 1800).each do |poll_setting| + PollGroupSetting.where("end_time < ? and end_time > ?", Time.now + 900, Time.now - 900).each do |poll_setting| poll = poll_setting.poll # poll.update_column('polls_status',3) From 0c77bf300c5cb5c246aeed2a7e7f88af804dd3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 5 Nov 2019 15:03:52 +0800 Subject: [PATCH 11/34] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/login/LoginDialog.js | 4 +++- public/react/src/modules/user/LoginRegisterComponent.js | 4 +++- public/react/src/modules/user/account/AccountBinding.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/login/LoginDialog.js b/public/react/src/modules/login/LoginDialog.js index 04cfa2e25..940e70c9a 100644 --- a/public/react/src/modules/login/LoginDialog.js +++ b/public/react/src/modules/login/LoginDialog.js @@ -539,7 +539,9 @@ class LoginDialog extends Component { } openphoneqqlogin=()=>{ - window.open(`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code`) + window.open( + `https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2ftest-newweb.educoder.net%2fotherloginqq&response_type=code` + ) } hideweixinlogin=()=>{ diff --git a/public/react/src/modules/user/LoginRegisterComponent.js b/public/react/src/modules/user/LoginRegisterComponent.js index a41c15cc0..55a42b62d 100644 --- a/public/react/src/modules/user/LoginRegisterComponent.js +++ b/public/react/src/modules/user/LoginRegisterComponent.js @@ -908,7 +908,9 @@ class LoginRegisterComponent extends Component { } openphoneqqlogin=()=>{ - window.open(`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code`) + window.open( + `https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2ftest-newweb.educoder.net%2fotherloginqq&response_type=code` + ) } render() { const { diff --git a/public/react/src/modules/user/account/AccountBinding.js b/public/react/src/modules/user/account/AccountBinding.js index eb62aa1e1..f5bf834d3 100644 --- a/public/react/src/modules/user/account/AccountBinding.js +++ b/public/react/src/modules/user/account/AccountBinding.js @@ -119,7 +119,9 @@ class AccountSecure extends Component { } openphoneqqlogin=()=>{ - window.open(`https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code`) + window.open( + `https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2ftest-newweb.educoder.net%2fotherloginqq&response_type=code` + ) } render() { let {basicInfo}=this.props; From 10dc5db970204d5624e326f104d6159a23d9a71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 5 Nov 2019 15:09:24 +0800 Subject: [PATCH 12/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/user/account/AccountBinding.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/public/react/src/modules/user/account/AccountBinding.js b/public/react/src/modules/user/account/AccountBinding.js index f5bf834d3..98ebc6a66 100644 --- a/public/react/src/modules/user/account/AccountBinding.js +++ b/public/react/src/modules/user/account/AccountBinding.js @@ -12,7 +12,6 @@ class AccountSecure extends Component { super(props) this.state = { Modalstype:false, - isphone:false, list:[{ en_type: "wechat", id: null, @@ -40,14 +39,9 @@ class AccountSecure extends Component { return flag; } componentDidMount() { - let flag = this.IsPC(); //true为PC端,false为手机端 let {basicInfo}=this.props; let {list}=this.state; - this.setState({ - isphone: flag - }) let newlist=list; - if(basicInfo===undefined||JSON.stringify(basicInfo) == "{}"||basicInfo&&basicInfo.open_users.length===0){ }else{ @@ -124,7 +118,7 @@ class AccountSecure extends Component { ) } render() { - let {basicInfo}=this.props; + let flag = this.IsPC(); //true为PC端,false为手机端 let {list}=this.state; return (
@@ -233,7 +227,7 @@ class AccountSecure extends Component { } >{item.id===null?"绑定":"解绑"}: this.openphoneqqlogin():() => this.openqqlogin():() => this.undologin("qq",item.id) + item.id===null?flag===true?() => this.openphoneqqlogin():() => this.openqqlogin():() => this.undologin("qq",item.id) } >{item.id===null?"绑定":"解绑"}}
From 0972872cfea85df2fa588d1aab0cf0a9c6e983f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Tue, 5 Nov 2019 15:20:20 +0800 Subject: [PATCH 13/34] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/exercise/new/SingleEditor.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/exercise/new/SingleEditor.js b/public/react/src/modules/courses/exercise/new/SingleEditor.js index f3c917c75..624315817 100644 --- a/public/react/src/modules/courses/exercise/new/SingleEditor.js +++ b/public/react/src/modules/courses/exercise/new/SingleEditor.js @@ -224,6 +224,10 @@ class SingleEditor extends Component{ // [true, false, true] -> [0, 2] const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1); + console.log("xuanzheshijuan"); + console.log(answerTagArray); + console.log(!exerciseIsPublish); + return(
@@ -87,9 +121,17 @@ class AccountCertification extends Component {
{ basicInfo && basicInfo.authentication =="uncertified" ? - this.checkBasicInfo(1)} >立即认证: - basicInfo && basicInfo.authentication =="applying" ? 待审核: - 已认证 + this.checkBasicInfo(1)} >立即认证: + basicInfo && basicInfo.authentication =="applying" ? + + this.cancelCertification(1)}>撤销认证 + 待审核 + + : + + this.checkBasicInfo(1)}>重新认证 + 已认证 + }
@@ -103,9 +145,18 @@ class AccountCertification extends Component {
{ basicInfo && basicInfo.professional_certification =="uncertified" ? - this.checkBasicInfo(2)} >立即认证: - basicInfo && basicInfo.professional_certification =="applying" ? 待审核: - 已认证 + this.checkBasicInfo(2)} >立即认证 + : + basicInfo && basicInfo.professional_certification =="applying" ? + + this.cancelCertification(2)}>撤销认证 + 待审核 + + : + + this.checkBasicInfo(2)} >重新认证 + 已认证 + }
diff --git a/public/react/src/modules/user/modal/RealNameCertificationModal.js b/public/react/src/modules/user/modal/RealNameCertificationModal.js index 53b32f679..4ac7f3c82 100644 --- a/public/react/src/modules/user/modal/RealNameCertificationModal.js +++ b/public/react/src/modules/user/modal/RealNameCertificationModal.js @@ -55,47 +55,45 @@ class RealNameCertificationModal extends Component{ } } - componentDidMount() { - console.log("RealNameCertificationModal"); - console.log(this.props.basicInfo); - if(this.props.basicInfo){ +// 弹框出现(visible==true)时给formitem赋值 + setVisible = (visible) => { + this.refs.modalWrapper.setVisible(visible); + if(visible && this.props.basicInfo){ this.setValue(this.props.basicInfo); this.getSchoolList(this.props.basicInfo); } } + setValue=(basicInfo)=>{ + // debugger; if(basicInfo){ this.props.form.setFieldsValue({ nickname:basicInfo.nickname, name:!basicInfo.show_realname ? this.hideRealName(basicInfo.name) : basicInfo.name, - sex:String(basicInfo.gender), job:basicInfo.identity, - org:basicInfo.school_name, - - // city:[basicInfo.location,basicInfo.location_city] + org:basicInfo.school_name }) setTimeout(() => { // 等显示后再set this.props.form.setFieldsValue({ job:basicInfo.identity, + sex:String(basicInfo.gender), student_No:basicInfo.student_id, org2:basicInfo.department_name, job1:basicInfo && basicInfo.identity=="teacher" ? basicInfo.technical_title:"教授", job2:basicInfo && basicInfo.identity=="professional" ? basicInfo.technical_title:"企业管理者", }) }, 100) - //if(basicInfo.nickname){ - this.setState({ - forDisable: true, - nameLength:basicInfo.nickname?basicInfo.nickname.length:0, - showRealName:basicInfo.show_realname, - realName: basicInfo.name, - identity:basicInfo.identity, - school_id:basicInfo.school_id, - department_id:basicInfo.department_id - }) - //} + this.setState({ + forDisable: true, + nameLength:basicInfo.nickname?basicInfo.nickname.length:0, + showRealName:basicInfo.show_realname, + realName: basicInfo.name, + identity:basicInfo.identity, + school_id:basicInfo.school_id, + department_id:basicInfo.department_id + }) } } @@ -256,10 +254,6 @@ class RealNameCertificationModal extends Component{ // } } - setVisible = (visible) => { - this.refs.modalWrapper.setVisible(visible) - } - onSendOk = () => { this.props.form.validateFieldsAndScroll((err, values) => { console.log(values); @@ -273,7 +267,7 @@ class RealNameCertificationModal extends Component{ // 实名认证 let url = `/users/accounts/${current_user && current_user.login}/authentication_apply.json` axios.post((url),{ - name:values.name, + name:values.name || basicInfo.name, gender:parseInt(values.sex), id_number:values.credentials }).then((result)=>{ @@ -289,8 +283,6 @@ class RealNameCertificationModal extends Component{ } this.setVisible(false); - - } }).catch((error)=>{ console.log(error);