Merge branches 'dev_aliyun' and 'develop' of https://bdgit.educoder.net/Hjqreturn/educoder into develop

dev_auth
杨树明 5 years ago
commit e22473cc15

@ -45,12 +45,14 @@ class ExercisePublishTask
Rails.logger.info("log--------------------------------exercise_end start") Rails.logger.info("log--------------------------------exercise_end start")
puts "--------------------------------exercise_end start" puts "--------------------------------exercise_end start"
# 1。统一设置的试卷 # 1。统一设置的试卷
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900) 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| exercises&.each do |exercise|
ex_type = exercise.exercise_questions.pluck(:question_type).uniq ex_type = exercise.exercise_questions.pluck(:question_type).uniq
exercise.update_column('exercise_status', 3) exercise.update_column('exercise_status', 3)
exercise.exercise_users&.each do |exercise_user| exercise.exercise_users&.each do |exercise_user|
begin 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?) if (exercise_user&.commit_status == 0) && (exercise_user&.start_at.present?)
s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] s_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
if ex_type.include?(4) #是否包含主观题 if ex_type.include?(4) #是否包含主观题
@ -60,6 +62,9 @@ class ExercisePublishTask
end end
total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = s_score + total_score_subjective_score total_score = s_score + total_score_subjective_score
Rails.logger.info("true: user_id:#{exercise_user.user_id}--subjective_score:#{subjective_score}")
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 = { commit_option = {
:status => 1, :status => 1,
:commit_status => 1, :commit_status => 1,
@ -94,6 +99,7 @@ class ExercisePublishTask
exercise_users = exercise.exercise_users.where(:user_id => users.pluck(:user_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|
begin 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 exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
if ex_types.include?(4) #是否包含主观题 if ex_types.include?(4) #是否包含主观题
subjective_score = exercise_user.subjective_score subjective_score = exercise_user.subjective_score
@ -103,6 +109,9 @@ class ExercisePublishTask
s_score = calculate_student_score(exercise, exercise_user.user)[:total_score] 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_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
total_score = s_score + total_score_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 = { commit_option = {
:status => 1, :status => 1,
:commit_status => 1, :commit_status => 1,

@ -50,10 +50,14 @@ function CourseGroupChooserModal({ course_groups = [], isAdminOrCreator, item, i
application_id: record.application_id, application_id: record.application_id,
approval: approval, approval: approval,
group_id: arg_course_groups group_id: arg_course_groups
}) }).then((result) => {
props.showNotification(`${approval == 1? '同意' : '拒绝'}`) if (result.data.status === 0) {
fetchAll(1) props.showNotification(`${approval == 1? '同意' : '拒绝'}`)
modalEl.current.setVisible(false) fetchAll(1)
modalEl.current.setVisible(false)
window.location.reload();
}})
} }
return ( return (
<ModalWrapper <ModalWrapper

@ -258,7 +258,7 @@ class studentsList extends Component{
// approval 2 - 拒绝 // approval 2 - 拒绝
onAgree = (record, approval = 1) => { onAgree = (record, approval = 1) => {
const isAdminOrCreator = this.props.isAdminOrCreator() const isAdminOrCreator = this.props.isAdminOrCreator()
const { course_groups } = this.state const { course_groups ,filterKey} = this.state
if (approval == 1 && isAdminOrCreator && course_groups && course_groups.length) { if (approval == 1 && isAdminOrCreator && course_groups && course_groups.length) {
this.setState({ clickRecord: record}, () => { this.setState({ clickRecord: record}, () => {
this.setGroupChooserModalVisible(true) this.setGroupChooserModalVisible(true)
@ -280,7 +280,7 @@ class studentsList extends Component{
.then((response) => { .then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.props.showNotification(`${approval == 1? '同意' : '拒绝'}`) this.props.showNotification(`${approval == 1? '同意' : '拒绝'}`)
this.fetchAll(1) this.fetchAll(1,filterKey)
} }
}) })
.catch(function (error) { .catch(function (error) {
@ -304,13 +304,15 @@ class studentsList extends Component{
this.setState({ this.setState({
filterKey:'1' filterKey:'1'
}) })
this.fetchAll(1,'1');
}else{ }else{
this.setState({ this.setState({
filterKey:'2' filterKey:'2'
}) })
this.fetchAll(1,'2');
} }
this.fetchAll(1);
const isAdminOrTeacher = this.props.isAdminOrTeacher() const isAdminOrTeacher = this.props.isAdminOrTeacher()
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
@ -330,10 +332,11 @@ class studentsList extends Component{
this.getCourseGroups() this.getCourseGroups()
} }
addTeacherSuccessListener = (e, data) => { addTeacherSuccessListener = (e, data) => {
// const params = JSON.parse(data) // const params = JSON.parse(data)
// const coursesId = this.props.match.params.coursesId // const coursesId = this.props.match.params.coursesId
if (window.location.pathname.endsWith('teachers')) { if (window.location.pathname.endsWith('teachers')) {
this.fetchAll(1) this.fetchAll(1,this.state.filterKey)
} else { } else {
// this.props.history.push(`/courses/${coursesId}/teachers`) // this.props.history.push(`/courses/${coursesId}/teachers`)
} }
@ -393,10 +396,10 @@ class studentsList extends Component{
}); });
} }
onChangeRoleSuccess = () => { onChangeRoleSuccess = () => {
this.fetchAll() this.fetchAll(undefined,this.state.filterKey)
} }
fetchAll = async (argPage) => { fetchAll = async (argPage,filterKey) => {
let { searchValue, filterKey }=this.state let { searchValue }=this.state
this.setState({ this.setState({
isSpin:true isSpin:true
@ -476,8 +479,8 @@ class studentsList extends Component{
// join_graduation_group // join_graduation_group
joinGraduationGroup = (graduation_group_id) => { joinGraduationGroup = (graduation_group_id) => {
const courseId = this.props.match.params.coursesId const courseId = this.props.match.params.coursesId
let { filterKey }=this.state
let url= `/courses/${courseId}/join_graduation_group.json`; let url= `/courses/${courseId}/join_graduation_group.json`;
axios.post(url, { axios.post(url, {
course_member_list: this.state.checkBoxValues.map (item => { return { course_member_id: item } }), course_member_list: this.state.checkBoxValues.map (item => { return { course_member_id: item } }),
@ -485,7 +488,7 @@ class studentsList extends Component{
}).then((result)=>{ }).then((result)=>{
if(result.data.status==0){ if(result.data.status==0){
this.props.showNotification('操作成功。') this.props.showNotification('操作成功。')
this.fetchAll() this.fetchAll(undefined,filterKey)
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
@ -493,6 +496,7 @@ class studentsList extends Component{
} }
onInputSearchChange = (e) => { onInputSearchChange = (e) => {
let {filterKey}=this.state;
this.setState({ this.setState({
searchValue: e.target.value searchValue: e.target.value
}) })
@ -501,12 +505,12 @@ class studentsList extends Component{
clearTimeout(this.timeoutHandler) clearTimeout(this.timeoutHandler)
} }
this.timeoutHandler = setTimeout(() => { this.timeoutHandler = setTimeout(() => {
this.fetchAll(1) this.fetchAll(1,filterKey)
}, 1200) }, 1200)
} }
onPressEnter = (e) => { onPressEnter = (e) => {
this.fetchAll(1) this.fetchAll(1,this.state.filterKey)
} }
@ -543,7 +547,7 @@ class studentsList extends Component{
changeRole = (member, role) => { changeRole = (member, role) => {
const courseId = this.props.match.params.coursesId const courseId = this.props.match.params.coursesId
let {filterKey}=this.state;
let url= `/courses/${courseId}/change_course_teacher.json`; let url= `/courses/${courseId}/change_course_teacher.json`;
axios.post(url, { axios.post(url, {
course_member_id: member.course_member_id course_member_id: member.course_member_id
@ -556,7 +560,7 @@ class studentsList extends Component{
}).then((result)=>{ }).then((result)=>{
if(result.data.status==0){ if(result.data.status==0){
this.props.showNotification('操作成功。') this.props.showNotification('操作成功。')
this.fetchAll() this.fetchAll(undefined,filterKey)
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
@ -572,9 +576,11 @@ class studentsList extends Component{
this.refs.addAdminModal.setVisible(true) this.refs.addAdminModal.setVisible(true)
} }
changeAdminSuccess = () => { changeAdminSuccess = () => {
this.fetchAll() let {filterKey}=this.state;
this.fetchAll(undefined,filterKey)
} }
onDelete = (member) => { onDelete = (member) => {
let {filterKey}=this.state;
this.props.confirm({ this.props.confirm({
content: `确认要将“${member.name}”从教师列表中移除吗?`, content: `确认要将“${member.name}”从教师列表中移除吗?`,
onOk: () => { onOk: () => {
@ -590,7 +596,7 @@ class studentsList extends Component{
// {"status":1,"message":"删除成功"} // {"status":1,"message":"删除成功"}
this.props.showNotification('删除成功') this.props.showNotification('删除成功')
trigger('updatabanner') trigger('updatabanner')
this.fetchAll() this.fetchAll(undefined,filterKey)
} }
}) })
.catch(function (error) { .catch(function (error) {
@ -615,12 +621,13 @@ class studentsList extends Component{
} }
onTableChange = (pagination, filters, sorter) => { onTableChange = (pagination, filters, sorter) => {
let {filterKey}=this.state;
console.log('Various parameters', pagination, filters, sorter); console.log('Various parameters', pagination, filters, sorter);
this.setState({ this.setState({
page: pagination.current, page: pagination.current,
sortedInfo: sorter, sortedInfo: sorter,
}, () => { }, () => {
this.fetchAll() this.fetchAll(undefined,filterKey)
}); });
}; };
clearSelection = () => { clearSelection = () => {
@ -633,7 +640,7 @@ class studentsList extends Component{
page:1, page:1,
isSpin:true isSpin:true
}, () => { }, () => {
this.fetchAll(); this.fetchAll(undefined,e.key);
}) })
} }
setGroupChooserModalVisible = (visible) => { setGroupChooserModalVisible = (visible) => {
@ -755,9 +762,11 @@ class studentsList extends Component{
<div className="mt20 edu-back-white padding20 teacherList"> <div className="mt20 edu-back-white padding20 teacherList">
{ course_groups && !!course_groups.length && <CourseGroupChooserModal { course_groups && !!course_groups.length && <CourseGroupChooserModal
{...this.state}
{...this.props}
props={{match: this.props.match, showNotification: this.props.showNotification}} props={{match: this.props.match, showNotification: this.props.showNotification}}
record={this.state.clickRecord} record={this.state.clickRecord}
fetchAll={this.fetchAll} fetchAll={(e)=>this.fetchAll(e,this.state.filterKey)}
course_groups={course_groups} course_groups={course_groups}
visible={this.state.groupChooserModalVisible} visible={this.state.groupChooserModalVisible}
setVisible={this.setGroupChooserModalVisible} setVisible={this.setGroupChooserModalVisible}

Loading…
Cancel
Save