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

topic_bank
cxt 5 years ago
commit f23180e5c8

@ -0,0 +1,149 @@
#coding=utf-8
# 执行示例 bundle exec rake public_course:student args=149,2903
# args 第一个参数是subject_id第二个参数是课程course_id
# 第一期时间2018-12-16 至2019-03-31
# 第二期时间2019-04-07 至2019-07-28
#
# 这次学习很有收获,感谢老师提供这么好的资源和细心的服务🎉🎉🎉
#
desc "同步精品课数据"
namespace :public_classes do
if ENV['args']
subject_id = ENV['args'].split(",")[0] # 对应课程的id
course_id = ENV['args'].split(",")[1] # 对应课堂的id
start_time = ENV['args'].split(",")[2] # 表示课程模块
end_time = ENV['args'].split(",")[3] # 表示课程模块
limit = ENV['args'].split(",")[4] # 限制导入的数量
type = ENV['args'].split(",")[5] # 表示课程模块
end
task :student => :environment do
puts "subject_id is #{subject_id}"
puts "course_id is #{course_id}"
user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where created_at between #{start_time} and #{end_time} and shixun_id in (select shixun_id from stage_shixuns
where stage_id in (select id from stages where subject_id=#{subject_id})) limit #{limit}").map(&:user_id)
puts user_ids
if user_ids.present?
user_ids.each do |user_id|
puts user_id
begin
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
rescue Exception => e
Rails.logger(e.message)
end
end
end
end
task :test_user => :environment do
users = User.where(is_test: true)
users.limit(limit).find_each do |user|
puts user.id
CourseMember.create!(course_id: course_id, user_id: user.id, role: 4)
end
end
# 更新某个课程的某类时间
# 执行示例 RAILS_ENV=production bundle exec rake public_course:time args=-1,2932,1,1
task :time => :environment do
# course_id = ENV['args'].split(",")[0] # 对应课堂的id
# type = ENV['args'].split(",")[1]
course = Course.find(course_id)
case type.to_i
when 1
# 讨论区
messages = Message.where(board_id: course.boards)
messages.each do |message|
created_on = random_time start_time, end_time
puts created_on
message.update_columns(created_on: created_on, updated_on: created_on)
MessageDetail.where(message_id: message.id).each do |detail|
rand_created_on = random_time start_time, end_time
detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on)
end
end
when 2
# 作业
course.homework_commons.each do |homework|
created_at = random_time(start_time, end_time)
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at)
homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at)
homework.student_works.where("work_status !=0 and update_time > '#{end_time}'").update_all(update_time: end_time)
end
when 3
# 试卷
course.exercises.each do |exercise|
created_at = random_time start_time, end_time
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
exercise.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at, exercise_status: 3)
end
when 4
# 资源
course.attachments.each do |atta|
created_on = random_time start_time, end_time
atta.update_columns(is_publish: 1, created_on: created_on, publish_time: created_on)
end
end
end
task :create_homework_work => :environment do
course = Course.find(course_id)
course.practice_homeworks.each do |homework|
if homework.student_works.count == 0
str = ""
CourseMember.students(course).each do |student|
str += "," if str != ""
str += "(#{homework.id},#{student.user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into student_works (homework_common_id, user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
def min_swith(time)
puts time
return time < 9 ? "0#{time}" : time
end
def random_time(start_time, end_time)
hour = (6..23).to_a.sample(1).first
min = rand(60)
sec = rand(60)
start_time = Date.parse(start_time)
end_time = Date.parse(end_time)
date = (start_time..end_time).to_a.sample(1).first
time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}"
puts time
time
end
def random_larger_time(time, start_time, end_time)
large_time = random_time(start_time, end_time)
while large_time <= time
large_time = random_time(start_time, end_time)
end
large_time
end
end

File diff suppressed because one or more lines are too long

@ -23,7 +23,6 @@
<title>EduCoder</title>
<script type="text/javascript">
window.__isR = true;
// 不支持ie9 ie10
if (
( navigator.userAgent.indexOf('MSIE 9') != -1
@ -33,7 +32,10 @@
// location.href = './compatibility'
location.href = '/compatibility.html'
}
const isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
if (isMobile) {
document.write('<script type="text/javascript" src="/javascripts/wx/jweixin-1.3.0.js"><\/script>');
}
</script>

@ -281,7 +281,58 @@ class App extends Component {
mydisplay:true,
})
};
initWXShare = () => {
if (window.wx) {
const wx = window.wx
const url = '/wechats/js_sdk_signature.json'
axios.post(url, {
url: 'http://pre-newweb.educoder.net',
}).then((response) => {
const data = response.data;
wx.config({
debug: false,
appId: data.appid,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: [
'onMenuShareTimeline',//
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'onMenuShareQZone'
]
});
wx.ready(function () {
var shareData = {
title: '这是是分享标题',
desc: '这是是摘要',
link: 'http://pre-newweb.educoder.net',
imgUrl: 'http://pre-newweb.educoder.net/images/educoder/index/subject/subject15.jpg'
};
wx.onMenuShareAppMessage(shareData);//分享给好友
wx.onMenuShareTimeline(shareData);//分享到朋友圈
wx.onMenuShareQQ(shareData);//分享给手机QQ
wx.onMenuShareWeibo(shareData);//分享腾讯微博
wx.onMenuShareQZone(shareData);//分享到QQ空间
});
wx.error(function (res) {
//alert(res.errMsg);//错误提示
});
}).catch((error) => {
console.log(error)
})
}
}
componentDidMount() {
// force an update if the URL changes
history.listen(() => {
this.forceUpdate()
@ -291,7 +342,7 @@ class App extends Component {
});
initAxiosInterceptors(this.props)
this.initWXShare()
//
// axios.interceptors.response.use((response) => {
// // console.log("response"+response);

@ -749,9 +749,9 @@ class Coursesleftnav extends Component{
{/*毕业设计*/}
{/*{item.type==="graduation"?<div onClick={()=>this.Navmodalnames(1,"attachment",item.id)}>添加目录</div>:""}*/}
{/*讨论区*/}
{item.type==="board"?<div onClick={e=>this.Navmodalnames(e,6,"board",item.main_id)}>添加目录</div>:""}
{item.type==="board"?this.props.current_user&&this.props.current_user.course_is_end===true?"":<div onClick={e=>this.Navmodalnames(e,6,"board",item.main_id)}>添加目录</div>:""}
{/*分班*/}
{item.type==="course_group"?<div onClick={e=>this.Navmodalnames(e,2,"course_group",item.id)}>添加分班</div>:""}
{item.type==="course_group"?this.props.current_user&&this.props.current_user.course_is_end===true?"":<div onClick={e=>this.Navmodalnames(e,2,"course_group",item.id)}>添加分班</div>:""}
{/*分班*/}
{/*{item.type==="course_group"? :""}*/}
<div onClick={e=>this.Navmodalnames(e,3,"editname",item.id,item.name)}>重命名</div>
@ -798,7 +798,6 @@ class Coursesleftnav extends Component{
// console.log("778");
// console.log("CoursesLeftNav");
// console.log(this.props);
// console.log(course_modules);
return(

@ -58,7 +58,7 @@ class Boards extends Component{
let {pageSize}=this.state;
const cid = this.props.match.params.coursesId
let url = `/courses/${cid}/graduation_topics.json?limit=`+pageSize
let url = `/courses/${cid}/graduation_topics.json?limit=${pageSize}`
if(searchValue!=""){
url+="&search="+searchValue
}
@ -68,7 +68,17 @@ class Boards extends Component{
if(status!="" && status != "all"){
url+="&status="+status;
}
axios.get(url).then((response) => {
url=encodeURI(url);//IE11传参为乱码search
axios.get(url
// ,{
// params:{
// search:encodeURI(searchValue),
// page:page,
// status:status,
// limit:pageSize
// }
// }
).then((response) => {
if (response.status == 200 && response.status) {
this.setState({
data:response.data,

@ -116,6 +116,7 @@ class Poll extends Component{
if(search!=""&&search!=undefined){
url+="&search="+search
}
url=encodeURI(url);//IE11传参为乱码search
axios.get(url).then((result)=>{
if(result){
this.setState({

@ -2641,7 +2641,7 @@ class Listofworksstudentone extends Component {
<ul className="clearfix" style={{padding: '20px 15px 10px 20px'}}>
<li className="clearfix ">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
{course_is_end===true?<span>
{course_is_end===true?"":<span>
{teacherdata&&teacherdata.publish_immediately===false&&computeTimetype===true?
(this.props.isNotMember()===false?<div className={"computeTime font-13"} onClick={this.setComputeTimet}>
计算成绩
@ -2651,7 +2651,7 @@ class Listofworksstudentone extends Component {
计算成绩
</div>:"")
}
</span>:""}
</span>}
<div className="fr mr5 search-newysl" style={{marginBottom: '1px'}}>
<Search

@ -188,6 +188,19 @@ function getLanguageByMirrorName(mirror_name) {
}
let notCallCodeMirrorOnChangeFlag = false;
/**
props :
mirror_name 决定语言
isEditablePath
repositoryCode
codemirrorDidMount
shixun.forbid_copy
showSettingDrawer, settingDrawerOpen
*/
class TPIMonaco extends Component {
constructor(props) {
@ -201,7 +214,7 @@ class TPIMonaco extends Component {
}
componentDidUpdate(prevProps, prevState, snapshot) {
const { game, mirror_name } = this.props
const { mirror_name } = this.props
const editor_monaco = this.editor_monaco;
if (editor_monaco && !_.isEqual(prevProps.mirror_name, mirror_name)) {
// TODO 后期考虑加入根据文件类型的不同使用不同的lang
@ -294,7 +307,7 @@ class TPIMonaco extends Component {
})
this.props.codemirrorDidMount && this.props.codemirrorDidMount()
if(this.props.shixun.forbid_copy == true) {
if(this.props.shixun && this.props.shixun.forbid_copy == true) {
// 禁用粘贴
// https://github.com/Microsoft/monaco-editor/issues/100
window.editor_monaco.onDidPaste( (a, b, c) => { window.__pastePosition = a })

Loading…
Cancel
Save