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

dev_ec^2
cxt 5 years ago
commit e883aec672

@ -0,0 +1,34 @@
class Weapps::BaseController < ApplicationController
private
def require_wechat_login!
return if session_unionid.present?
render_error('请先进行微信授权')
end
def weapp_session_key
Wechat::Weapp.session_key(session_openid)
end
def set_weapp_session_key(session_key)
Wechat::Weapp.write_session_key(session_openid, session_key)
end
def session_openid
session[:openid]
end
def set_session_openid(openid)
session[:openid] = openid
end
def session_unionid
session[:unionid]
end
def set_session_unionid(unionid)
session[:unionid] = unionid
end
end

@ -0,0 +1,24 @@
class Weapps::CodeSessionsController < Weapps::BaseController
def create
return render_error('code不能为空') if params[:code].blank?
result = Wechat::Weapp.jscode2session(params[:code])
set_session_openid(result['openid'])
set_weapp_session_key(result['session_key']) # weapp session_key写入缓存 后续解密需要
# 已授权,绑定过账号
open_user = OpenUser::Wechat.find_by(uid: result['unionid'])
if open_user.present? && open_user.user
set_session_unionid(result['unionid'])
successful_authentication(open_user.user)
else
# 新用户
user_info = Wechat::Weapp.decrypt(result['session_key'], params[:encrypted_data], params[:iv])
set_session_unionid(user_info['unionId'])
end
render_ok(openid: result['openid'])
end
end

@ -0,0 +1,12 @@
class Weapps::HomesController < Weapps::BaseController
def show
# banner图
@images = PortalImage.where(status: true).order(position: :asc)
# 热门实训
@shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(4)
# 热门实践课程
@subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(4)
end
end

@ -0,0 +1,63 @@
class Weapps::RegistersController < Weapps::BaseController
before_action :require_wechat_login!
def create
# 查询验证码是否正确;type只可能是1或者8
type = phone_mail_type(params[:login].strip)
code = params[:code].strip
if type == 1
uid_logger("start register by phone: type is #{type}")
pre = 'p'
email = nil
phone = params[:login]
verifi_code = VerificationCode.where(phone: phone, code: code, code_type: 1).last
else
uid_logger("start register by email: type is #{type}")
pre = 'm'
email = params[:login]
phone = nil
verifi_code = VerificationCode.where(email: email, code: code, code_type: 8).last
end
uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}")
# check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
# todo 上线前请删除万能验证码"513231"
unless code == "513231" && request.subdomain == "test-newweb"
return render_error('验证码不正确') if verifi_code.try(:code) != code.strip
return render_error('验证码已失效') if !verifi_code&.effective?
end
login = User.generate_login(pre)
@user = User.new(admin: false, login: login, mail: email, phone: phone, type: 'User')
@user.password = params[:password]
# 现在因为是验证码,所以在注册的时候就可以激活
@user.activate
# 必须要用save操作密码的保存是在users中
ActiveRecord::Base.transaction do
@user.save!
UserExtension.create!(user_id: @user.id)
# 绑定微信号
OpenUsers::Wechat.create!(user: @user, uid: session_unionid)
# 注册完成手机号或邮箱想可以奖励500金币
RewardGradeService.call(
@user,
container_id: @user.id,
container_type: pre == 'p' ? 'Phone' : 'Mail',
score: 500
)
end
successful_authentication(@user)
session[:user_id] = @user.id
render_ok
end
private
# 1 手机类型0 邮箱类型
# 注意新版的login是自动名生成的
def phone_mail_type value
value =~ /^1\d{10}$/ ? 1 : 0
end
end

@ -0,0 +1,24 @@
class Weapps::SessionsController < Weapps::BaseController
before_action :require_wechat_login!
def create
return render_error('重复登录') if current_user.present? && current_user.logged?
user = User.try_to_login(params[:login], params[:password])
return render_error('错误的账号或密码') if user.blank?
return render_error('违反平台使用规范,账号已被锁定') if user.locked?
return render_error('错误的账号或密码') unless user.check_password?(params[:password].to_s)
if user.wechat_open_user && user.wechat_open_user.uid != session_unionid
render_error('该账号已被其它微信号绑定')
return
end
# 绑定微信号
OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank?
successful_authentication(user)
render_ok
end
end

@ -0,0 +1,8 @@
class Weapps::VerifiesController < Weapps::BaseController
before_action :require_wechat_login!
def create
valid = Wechat::Weapp.verify?(session_openid, params[:verify_string], params[:signature])
render_ok(valid: valid)
end
end

@ -0,0 +1,22 @@
class HotSearchKeyword
class << self
def add(keyword)
return if keyword.blank?
Rails.cache.data.zincrby(redis_key, 1, keyword)
end
def hot(limit = 5)
Rails.cache.data.zrevrange(redis_key, 0, limit - 1)
end
def available?
Rails.cache.is_a?(ActiveSupport::Cache::RedisStore)
end
private
def redis_key
'educoder:es:hot_keyword'
end
end
end

@ -1,4 +1,4 @@
class Wechat::App class Wechat::Weapp
class << self class << self
attr_accessor :appid, :secret attr_accessor :appid, :secret
@ -7,5 +7,41 @@ class Wechat::App
def client def client
@_client ||= Wechat::Client.new(appid, secret) @_client ||= Wechat::Client.new(appid, secret)
end end
def session_key(openid)
Rails.cache.read(session_key_cache_key(openid))
end
def write_session_key(openid, session_key)
Rails.cache.write(session_key_cache_key(openid), session_key)
end
def verify?(openid, str, signature)
session_key = session_key(openid)
Digest::SHA1.hexdigest("#{str}#{session_key}") == signature
end
def decrypt(session_key, encrypted_data, iv)
session_key = Base64.decode64(session_key)
encrypted_data = Base64.decode64(encrypted_data)
iv = Base64.decode64(iv)
cipher = OpenSSL::Cipher::AES.new(128, :CBC)
cipher.decrypt
cipher.padding = 0
cipher.key = session_key
cipher.iv = iv
data = cipher.update(encrypted_data) << cipher.final
result = JSON.parse(data[0...-data.last.ord])
raise Wechat::Error, '解密错误' if result.dig('watermark', 'appid') != appid
result
end
private
def session_key_cache_key(openid)
"weapp:#{appid}:#{openid}:session_key"
end
end end
end end

@ -17,7 +17,7 @@ class CreateBindUserService < ApplicationService
bind_user = User.try_to_login(params[:username], params[:password]) bind_user = User.try_to_login(params[:username], params[:password])
raise Error, '用户名或者密码错误' if bind_user.blank? raise Error, '用户名或者密码错误' if bind_user.blank?
raise Error, '该账号已被绑定' if bind_user.bind_open_user?(params[:type].to_s) raise Error, '该账号已被其他微信号绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s)
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
open_user.user_id = bind_user.id open_user.user_id = bind_user.id

@ -0,0 +1,14 @@
json.images do
json.array! @images do |image|
json.path image.link
json.image_url Util::FileManage.source_disk_file_url(image)
end
end
json.shixuns do
json.partial! 'shixuns/shixun', locals: { shixuns: @shixuns }
end
json.subjects do
json.partial! 'subjects/subject', locals: { subjects: @subjects }
end

@ -18,6 +18,9 @@ defaults: &defaults
wechat: wechat:
appid: 'test' appid: 'test'
secret: 'test' secret: 'test'
weapp:
appid: 'test'
secret: 'test'
development: development:
<<: *defaults <<: *defaults

@ -1,9 +1,12 @@
wechat_config = {} wechat_config = {}
weapp_config = {}
begin begin
config = Rails.application.config_for(:configuration) config = Rails.application.config_for(:configuration)
wechat_config = config['wechat'] wechat_config = config['wechat']
weapp_config = config['weapp']
raise 'wechat config missing' if wechat_config.blank? raise 'wechat config missing' if wechat_config.blank?
raise 'weapp config missing' if weapp_config.blank?
rescue => ex rescue => ex
raise ex if Rails.env.production? raise ex if Rails.env.production?
@ -12,5 +15,10 @@ rescue => ex
wechat_config = {} wechat_config = {}
end end
# 网站应用
Wechat::OfficialAccount.appid = wechat_config['appid'] Wechat::OfficialAccount.appid = wechat_config['appid']
Wechat::OfficialAccount.secret = wechat_config['secret'] Wechat::OfficialAccount.secret = wechat_config['secret']
# 小程序
Wechat::Weapp.appid = weapp_config['appid']
Wechat::Weapp.secret = weapp_config['secret']

@ -829,6 +829,14 @@ Rails.application.routes.draw do
get '/auth/qq/callback', to: 'oauth/qq#create' get '/auth/qq/callback', to: 'oauth/qq#create'
get '/auth/wechat/callback', to: 'oauth/wechat#create' get '/auth/wechat/callback', to: 'oauth/wechat#create'
resource :bind_user, only: [:create] resource :bind_user, only: [:create]
namespace :weapps do
resource :home, only: [:show]
resource :session, only: [:create]
resource :register, only: [:create]
resource :code_session, only: [:create]
resource :verify, only: [:create]
end
end end
namespace :admins do namespace :admins do

@ -28,7 +28,7 @@ class Fileslists extends Component{
pagesize: 15, pagesize: 15,
tagname:undefined, tagname:undefined,
search:undefined, search:undefined,
sort:undefined, sort:"desc",
sorttype:"created_on", sorttype:"created_on",
coursesecondcategoryid:undefined, coursesecondcategoryid:undefined,
filesId:undefined, filesId:undefined,
@ -49,16 +49,19 @@ class Fileslists extends Component{
checkBoxValues:[], checkBoxValues:[],
checkAllValue:false checkAllValue:false
}) })
if(this.props.match.params.main_id){ if(this.props.match.params.main_id){
this.seactall();
this.setState({ this.setState({
child:false, child:false,
sort:"desc"
}) })
this.seactall(undefined,"desc");
}else if(this.props.match.params.Id){ }else if(this.props.match.params.Id){
this.seactall(parseInt(this.props.match.params.Id),1)
this.setState({ this.setState({
child:true, child:true,
sort:"desc"
}) })
this.seactall(parseInt(this.props.match.params.Id),"desc")
} }
this.updadatalist(); this.updadatalist();
on('updateNavSuccess', this.updateNavSuccess) on('updateNavSuccess', this.updateNavSuccess)
@ -66,13 +69,14 @@ class Fileslists extends Component{
} }
updateNavSuccess=()=>{ updateNavSuccess=()=>{
let{sort}=this.state;
this.setState({ this.setState({
isSpin:true isSpin:true
}) })
if(this.props.match.params.main_id){ if(this.props.match.params.main_id){
this.seactall(); this.seactall(undefined,sort);
}else if(this.props.match.params.Id){ }else if(this.props.match.params.Id){
this.seactall(parseInt(this.props.match.params.Id),1) this.seactall(parseInt(this.props.match.params.Id),sort)
} }
} }
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
@ -85,8 +89,9 @@ class Fileslists extends Component{
if(this.props.match.params.main_id!=undefined){ if(this.props.match.params.main_id!=undefined){
this.setState({ this.setState({
child:false, child:false,
sort:"desc"
}) })
this.seactall(); this.seactall(undefined,"desc");
} }
} }
if(prevProps.match.params.Id != this.props.match.params.Id){ if(prevProps.match.params.Id != this.props.match.params.Id){
@ -98,8 +103,9 @@ class Fileslists extends Component{
if(this.props.match.params.Id!=undefined){ if(this.props.match.params.Id!=undefined){
this.setState({ this.setState({
child:true, child:true,
sort:"desc"
}) })
this.seactall(parseInt(this.props.match.params.Id),1) this.seactall(parseInt(this.props.match.params.Id),"desc")
} }
} }
} }
@ -138,29 +144,42 @@ class Fileslists extends Component{
} }
updatafiled=()=>{ updatafiled=()=>{
let{sort}=this.state;
if(this.props.match.params.main_id){ if(this.props.match.params.main_id){
this.seactall(); this.seactall(undefined,sort);
}else if(this.props.match.params.Id){ }else if(this.props.match.params.Id){
this.seactall(parseInt(this.props.match.params.Id),1) this.seactall(parseInt(this.props.match.params.Id),sort)
} }
} }
seactall=(coursesecondcategoryid,type)=>{ seactall=(coursesecondcategoryid,sort)=>{
this.setState({ this.setState({
coursesecondcategoryid:coursesecondcategoryid, coursesecondcategoryid:coursesecondcategoryid,
isSpin:true isSpin:true
}) })
let{pagesize,page,tagname,searchValue,sort,sorttype}=this.state; let{pagesize,page,tagname,searchValue,sorttype}=this.state;
this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid); this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid);
} }
onSortTypeChange=(sorttype)=>{ onSortTypeChange=(sorttype)=>{
let{pagesize,page,tagname,searchValue,sort,coursesecondcategoryid}=this.state; let{pagesize,page,tagname,searchValue,sort,coursesecondcategoryid,}=this.state;
let newsort="desc";
if(sort==="desc"){
this.setState({ this.setState({
sorttype:sorttype sorttype:sorttype,
sort:"asc"
}) })
this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid); newsort="asc"
}else{
this.setState({
sorttype:sorttype,
sort:"desc"
})
newsort="desc"
}
this.getfileslist(pagesize,page,tagname,searchValue,newsort,sorttype,coursesecondcategoryid);
} }
getfileslist=(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid)=>{ getfileslist=(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid)=>{
@ -176,7 +195,7 @@ class Fileslists extends Component{
page:page, page:page,
tag_name:tagname, tag_name:tagname,
search:searchValue, search:searchValue,
sort:sort, sort:sort==="desc"?0:1,
sort_type:sorttype, sort_type:sorttype,
course_second_category_id:id course_second_category_id:id
} }
@ -353,7 +372,7 @@ class Fileslists extends Component{
Modalstype:false, Modalstype:false,
}) })
let {checkBoxValues} = this.state; let {checkBoxValues,sort} = this.state;
const cid = this.props.match.params.coursesId; const cid = this.props.match.params.coursesId;
let url="/files/bulk_public.json"; let url="/files/bulk_public.json";
@ -363,7 +382,7 @@ class Fileslists extends Component{
}) })
.then((response) => { .then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.seactall(); this.updatafiled()
//:response.data.message //:response.data.message
this.props.showNotification("更新成功"); this.props.showNotification("更新成功");
this.setState({ this.setState({
@ -680,7 +699,8 @@ class Fileslists extends Component{
shixunmodal, shixunmodal,
course_is_public, course_is_public,
filesId, filesId,
child child,
sort
} = this.state; } = this.state;
let category_id= this.props.match.params.category_id; let category_id= this.props.match.params.category_id;
@ -753,7 +773,7 @@ class Fileslists extends Component{
patheditarry={this.state.patheditarry} patheditarry={this.state.patheditarry}
coursesecondcategoryid={this.state.coursesecondcategoryid} coursesecondcategoryid={this.state.coursesecondcategoryid}
hidecouseShixunModal={this.hidecouseShixunModal} hidecouseShixunModal={this.hidecouseShixunModal}
setupdate={(id)=>this.seactall(id)} setupdate={(id)=>this.seactall(id,sort)}
attachmentId={this.state.coursesecondcategoryid} attachmentId={this.state.coursesecondcategoryid}
/>:""} />:""}
@ -768,7 +788,7 @@ class Fileslists extends Component{
Savesname={"确认"} Savesname={"确认"}
Cancel={this.Cancelvisible} Cancel={this.Cancelvisible}
categoryid={category_id} categoryid={category_id}
setupdate={(id)=>this.seactall(id)} setupdate={(id)=>this.seactall(id,sort)}
has_course_groups={this.state.has_course_groups} has_course_groups={this.state.has_course_groups}
attachmentId={this.state.coursesecondcategoryid} attachmentId={this.state.coursesecondcategoryid}
/>:""} />:""}
@ -779,7 +799,7 @@ class Fileslists extends Component{
Settingtype={Settingtype} Settingtype={Settingtype}
discussMessageid={discussMessageid} discussMessageid={discussMessageid}
course_id={this.props.match.params.coursesId} course_id={this.props.match.params.coursesId}
setupdate={(id)=>this.seactall(id)} setupdate={(id)=>this.seactall(id,sort)}
Cancel={this.Cancelvisible} Cancel={this.Cancelvisible}
has_course_groups={this.state.has_course_groups} has_course_groups={this.state.has_course_groups}
attachmentId={this.state.coursesecondcategoryid} attachmentId={this.state.coursesecondcategoryid}
@ -896,16 +916,24 @@ class Fileslists extends Component{
</li>:""} </li>:""}
<style>
{this.props.isAdmin()||this.props.isStudent()? <li className="drop_down"> {
{sorttype === 'created_on' ? '更新时间排序':sorttype === 'downloads' ?'下载次数排序':'引用次数排序'} `
<i className="iconfont icon-xiajiantou font-12 ml2"></i> .fiilssort{
<ul className="drop_down_normal" style={{width:'130px'}}> position: absolute;
{/*className={sorttype === 'created_on'?"none":""} className={sorttype === 'quotes'?"none":""} className={sorttype === 'downloads'?"none":""} */} top: -10px;
<li style={{width:'130px'}} onClick={() => this.onSortTypeChange('created_on')}>更新时间排序</li> }
<li style={{width:'130px'}} onClick={() => this.onSortTypeChange('downloads')}>下载次数排序</li> `
{/*<li style={{width:'130px'}} onClick={() => this.onSortTypeChange('quotes')}>引用次数排序</li>*/} }
</ul> </style>
{this.props.isAdmin()||this.props.isStudent()? <li className="drop_down" onClick={() => this.onSortTypeChange('created_on')}>
更新时间
<sapn className="relativef ml5"style={{"top":"2px"}} >
<i className={sort==="asc"?
"iconfont icon-sanjiaoxing-up font-12 color-blue fiilssort" :"iconfont icon-sanjiaoxing-up font-12 fiilssort"}></i>
<i className={sort==="desc"?
"iconfont icon-sanjiaoxing-down font-12 yslbottomsj color-blue":"iconfont icon-sanjiaoxing-down font-12 yslbottomsj"}></i>
</sapn>
</li>:""} </li>:""}
</div> </div>
</div> </div>

@ -1129,6 +1129,8 @@ class CommonWorkSetting extends Component{
{<div className={"publicTimeTip color-red ml30"}>{publicTimeTip}</div>} {<div className={"publicTimeTip color-red ml30"}>{publicTimeTip}</div>}
</React.Fragment> : </React.Fragment> :
adaptered_group_settings && !!adaptered_group_settings.length && <PollDetailTabForthRules adaptered_group_settings && !!adaptered_group_settings.length && <PollDetailTabForthRules
{...this.props}
{...this.state}
ref="pollDetailTabForthRules" ref="pollDetailTabForthRules"
rules={rules} rules={rules}
course_group={adaptered_group_settings} course_group={adaptered_group_settings}

@ -61,7 +61,8 @@ class Titlesearchsection extends Component{
<p className="clearfix padding30 bor-bottom-greyE"> <p className="clearfix padding30 bor-bottom-greyE">
<p style={{height: '20px'}}> <p style={{height: '20px'}}>
<span className="font-18 fl color-dark-21 filesnameslist" title={title}>{title}</span> {/* title={title} */}
<span className="font-18 fl color-dark-21 filesnameslist" >{title}</span>
<li className="fr font-16"> <li className="fr font-16">
{ firstRowRight } { firstRowRight }
</li> </li>

@ -248,8 +248,8 @@ class CoursesBanner extends Component {
} }
} }
if (i ===5) { if (i ===5) {
s = "复制将在后台执行,作业、资源、试卷都将复制到新课堂平台"; s = "复制”功能将会为您创建一个新的课堂旧课堂的作业、资源、试卷";
ss = "将为你创建一个新的同名课堂,请问是否继续"; ss = "都将被复制到新的课堂里面请问是否继续?";
this.showActionPoll(i,s,ss) this.showActionPoll(i,s,ss)
} }

@ -350,6 +350,7 @@ class Exercisesetting extends Component{
this.commitSetting((result)=>{ this.commitSetting((result)=>{
console.log(result)
if(result.status==200){ if(result.status==200){
this.props.showNotification(`${result.data.message}`); this.props.showNotification(`${result.data.message}`);
this.getSettingInfo(); this.getSettingInfo();
@ -369,6 +370,7 @@ class Exercisesetting extends Component{
} }
this.commitSetting((result)=>{ this.commitSetting((result)=>{
console.log(result)
if(result.status==200){ if(result.status==200){
this.props.showNotification(`${result.data.message}`); this.props.showNotification(`${result.data.message}`);
this.cancelEdit(); this.cancelEdit();
@ -702,6 +704,8 @@ class Exercisesetting extends Component{
</div> </div>
: :
<PollDetailTabForthRules <PollDetailTabForthRules
{...this.props}
{...this.state}
ref="pollDetailTabForthRules" ref="pollDetailTabForthRules"
rules={rules} rules={rules}
type={"Exercise"} type={"Exercise"}

@ -257,6 +257,15 @@ class Testpapersettinghomepage extends Component{
if(tab[0]==="0"){ if(tab[0]==="0"){
this.child.Teacherliststudentlist(); this.child.Teacherliststudentlist();
} }
if(tab[0]==="1"){
this.child.Teacherliststudentlist();
}
if(tab[0]==="2"){
this.child.Teacherliststudentlist();
}
if(tab[0]==="3"){
this.child.getSettingInfo();
}
}catch (e) { }catch (e) {
} }

@ -710,7 +710,7 @@ class studentsList extends Component{
title={isParent ? (pageType == TYPE_STUDENTS ? "全部学生" : "学生列表"): title={isParent ? (pageType == TYPE_STUDENTS ? "全部学生" : "学生列表"):
<React.Fragment> <React.Fragment>
<span> <span>
<Tooltip title="返回"> <Tooltip title="返回至分班列表">
<i className="icon-zuojiantou iconfont font-14" onClick={() => { this.props.history.push(`/courses/${courseId}/course_groups`)}} <i className="icon-zuojiantou iconfont font-14" onClick={() => { this.props.history.push(`/courses/${courseId}/course_groups`)}}
style={{color: '#212121', verticalAlign: 'initial', marginRight: '14px' }} style={{color: '#212121', verticalAlign: 'initial', marginRight: '14px' }}
></i> ></i>

@ -49,6 +49,24 @@ class PollDetailIndex extends Component{
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
}) })
let{tab}=this.state;
try {
if(tab[0]==="0"){
this.child.Teacherliststudentlist();
}
if(tab[0]==="1"){
this.child.Teacherliststudentlist();
}
if(tab[0]==="2"){
this.child.Teacherliststudentlist();
}
if(tab[0]==="3"){
this.child.getSettingInfo();
}
}catch (e) {
}
} }
componentDidMount(){ componentDidMount(){
@ -110,6 +128,7 @@ class PollDetailIndex extends Component{
DownloadMessageval:undefined DownloadMessageval:undefined
}) })
} }
bindRef = ref => { this.child = ref };
render(){ render(){
let {tab,pollDetail,user_permission,polls_status}=this.state; let {tab,pollDetail,user_permission,polls_status}=this.state;
const { current_user } = this.props; const { current_user } = this.props;
@ -235,7 +254,7 @@ class PollDetailIndex extends Component{
} }
{ {
//设置 //设置
parseInt(tab[0])==3 && <PollTabForth {...this.props} {...this.state} user_permission={user_permission} getPollInfo={this.getPollInfo}></PollTabForth> parseInt(tab[0])==3 && <PollTabForth {...this.props} {...this.state} triggerRef={this.bindRef} user_permission={user_permission} getPollInfo={this.getPollInfo}></PollTabForth>
} }
</div> </div>

@ -90,6 +90,11 @@ class PollDetailTabForth extends Component{
if(this.props.isAdmin() === false){ if(this.props.isAdmin() === false){
this.cancelEdit() this.cancelEdit()
} }
try {
this.props.triggerRef(this);
}catch (e) {
}
} }
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
if(prevProps.pollDetail!= this.props.pollDetail){ if(prevProps.pollDetail!= this.props.pollDetail){
@ -610,6 +615,8 @@ class PollDetailTabForth extends Component{
</div> </div>
: :
<PollDetailTabForthRules <PollDetailTabForthRules
{...this.props}
{...this.state}
ref="pollDetailTabForthRules" ref="pollDetailTabForthRules"
rules={rules} rules={rules}
course_group={course_group} course_group={course_group}

@ -342,7 +342,7 @@ class PollDetailTabForthRules extends Component{
} }
render(){ render(){
let {rules,course_group,flagPageEdit}=this.state let {rules,course_group,flagPageEdit}=this.state
console.log(rules) let isAdmin=this.props.isAdmin();
return( return(
<div className="bor-top-greyE pt20"> <div className="bor-top-greyE pt20">
<p className="clearfix mb10"> <p className="clearfix mb10">
@ -350,6 +350,12 @@ class PollDetailTabForthRules extends Component{
<span className="fl pr20 color-grey-c with25">(学生收到{this.props.moduleName || (this.props.type==="Exercise"?"试卷":"问卷")}的时间)</span> <span className="fl pr20 color-grey-c with25">(学生收到{this.props.moduleName || (this.props.type==="Exercise"?"试卷":"问卷")}的时间)</span>
<span className="fl color-grey-c">({this.props.moduleName == '作业' ? '学生“按时”提交作品的时间截点' : '学生可以答题的时间截点'})</span> <span className="fl color-grey-c">({this.props.moduleName == '作业' ? '学生“按时”提交作品的时间截点' : '学生可以答题的时间截点'})</span>
</p> </p>
{/* item宽度超长 */}
<style>{`
.setInfo .ant-select-selection--multiple .ant-select-selection__choice__content {
max-width: 300px;
}
`}</style>
{ {
rules && rules.length > 0 && rules.map((rule,r)=>{ rules && rules.length > 0 && rules.map((rule,r)=>{
@ -383,7 +389,8 @@ class PollDetailTabForthRules extends Component{
`.ant-select{ `.ant-select{
min-width:200px, min-width:200px,
min-heigth:200px min-heigth:200px
}` }
`
} }
</style> </style>
<Select <Select
@ -395,7 +402,7 @@ class PollDetailTabForthRules extends Component{
} }
value={rule.course_group_id} value={rule.course_group_id}
onChange={(value,option)=>this.changeClasses(value,option,r)} onChange={(value,option)=>this.changeClasses(value,option,r)}
disabled={ rule.e_timeflag ===undefined?rule.publish_time===null?false:!flagPageEdit:rule.p_timeflag == true ? true : !flagPageEdit} disabled={rule.p_timeflag===undefined?moment(rule.publish_time,dataformat) <= moment()?true:!flagPageEdit: rule.e_timeflag ===undefined?rule.publish_time===null?false:!flagPageEdit:rule.p_timeflag == true ? true : !flagPageEdit}
> >
{ {
courseGroup && courseGroup.length > 0 && courseGroup.map((team,t)=>{ courseGroup && courseGroup.length > 0 && courseGroup.map((team,t)=>{
@ -413,7 +420,9 @@ class PollDetailTabForthRules extends Component{
</div> </div>
</div> </div>
<div className="fl pr20 with25 yskspickersy"> <div className="fl pr20 with25 yskspickersy">
<Tooltip placement="bottom" title={rule.e_timeflag ? this.props.isAdmin()?"发布时间已过,不能再修改":"":""}> <Tooltip placement="bottom" title={
rule.p_timeflag===undefined?moment(rule.publish_time,dataformat) <= moment()?isAdmin===true?"发布时间已过,不能再修改":"":"": rule.e_timeflag ===undefined?rule.publish_time===null?"":!flagPageEdit:rule.p_timeflag == true ? isAdmin===true?"发布时间已过,不能再修改":"" : ""
}>
<span> <span>
<DatePicker <DatePicker
showToday={false} showToday={false}
@ -427,7 +436,7 @@ class PollDetailTabForthRules extends Component{
format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
disabledTime={disabledDateTime} disabledTime={disabledDateTime}
disabledDate={disabledDate} disabledDate={disabledDate}
disabled={ rule.e_timeflag ===undefined?rule.publish_time===null?false:!flagPageEdit:rule.p_timeflag == true ? true : !flagPageEdit} disabled={ rule.p_timeflag===undefined?moment(rule.publish_time,dataformat) <= moment()?true:!flagPageEdit: rule.e_timeflag ===undefined?rule.publish_time===null?false:!flagPageEdit:rule.p_timeflag == true ? true : !flagPageEdit}
style={{"height":"42px",width:'100%'}} style={{"height":"42px",width:'100%'}}
></DatePicker> ></DatePicker>
</span> </span>

@ -2261,6 +2261,8 @@ class Trainingjobsetting extends Component {
className="ml40" className="ml40"
> >
<PollDetailTabForthRules <PollDetailTabForthRules
{...this.props}
{...this.state}
rules={rules} rules={rules}
moduleName={"作业"} moduleName={"作业"}
course_group={rulest} course_group={rulest}

@ -109,7 +109,7 @@
right: -27px; right: -27px;
z-index: 100000; z-index: 100000;
} }
#logincloseIcon{ .logincloseIcon{
position: absolute; position: absolute;
top: -100px; top: -100px;
right: -27px; right: -27px;

@ -913,7 +913,7 @@ submittojoinclass=(value)=>{
strbool=false strbool=false
} }
} }
console.log(item.hidden); // console.log(item.hidden);
return( return(
<li key={key} onClick={()=>this.headtypesonClick(item.link,true)} className={`${headtypes===undefined?'pr':headtypes===item.link?'pr active':'pr'}`} style={item.hidden==false?{display: 'block'}:{display: 'none'}}> <li key={key} onClick={()=>this.headtypesonClick(item.link,true)} className={`${headtypes===undefined?'pr':headtypes===item.link?'pr active':'pr'}`} style={item.hidden==false?{display: 'block'}:{display: 'none'}}>
{ {

Loading…
Cancel
Save