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

competitions
SylorHuang 5 years ago
commit 715ff80b1d

@ -552,7 +552,7 @@ class CoursesController < ApplicationController
def change_member_role def change_member_role
tip_exception("请至少选择一个角色") if params[:roles].blank? tip_exception("请至少选择一个角色") if params[:roles].blank?
tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR") tip_exception("不能具有老师、助教两种角色") if params[:roles].include?("PROFESSOR") && params[:roles].include?("ASSISTANT_PROFESSOR")
tip_exception("管理员不能切换为助教或老师") if @user_course_identity == Course::CREATOR && tip_exception("管理员不能切换为助教或老师") if params[:user_id].to_i == @course.tea_id &&
(params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR"))
course_members = @course.course_members.where(user_id: params[:user_id]) course_members = @course.course_members.where(user_id: params[:user_id])

@ -694,6 +694,7 @@ class ExercisesController < ApplicationController
#首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。
def publish def publish
group_ids = params[:group_ids]&.reject(&:blank?)
if params[:detail].blank? if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
@ -701,7 +702,6 @@ class ExercisesController < ApplicationController
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_ids = params[:group_ids].reject(&:blank?)
tip_exception("缺少截止时间参数") if group_end_times.blank? tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time| group_end_times.each do |time|

@ -1044,6 +1044,7 @@ class HomeworkCommonsController < ApplicationController
def publish_homework def publish_homework
tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0 tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0
group_ids = params[:group_ids]&.reject(&:blank?)
if params[:detail].blank? if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
@ -1051,7 +1052,6 @@ class HomeworkCommonsController < ApplicationController
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_ids = params[:group_ids].reject(&:blank?)
tip_exception("缺少截止时间参数") if group_end_times.blank? tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time| group_end_times.each do |time|

@ -254,6 +254,7 @@ class PollsController < ApplicationController
#首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。
def publish def publish
group_ids = params[:group_ids]&.reject(&:blank?)
if params[:detail].blank? if params[:detail].blank?
tip_exception("缺少截止时间参数") if params[:end_time].blank? tip_exception("缺少截止时间参数") if params[:end_time].blank?
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
@ -261,7 +262,6 @@ class PollsController < ApplicationController
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
else else
group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time} group_end_times = params[:group_end_times].reject(&:blank?).map{|time| time.to_time}
group_ids = params[:group_ids].reject(&:blank?)
tip_exception("缺少截止时间参数") if group_end_times.blank? tip_exception("缺少截止时间参数") if group_end_times.blank?
tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length tip_exception("截止时间和分班参数的个数不一致") if group_end_times.length != group_ids.length
group_end_times.each do |time| group_end_times.each do |time|

@ -90,23 +90,25 @@ class QuestionBanksController < ApplicationController
def send_to_course def send_to_course
banks = @object_type.classify.constantize.where(id: params[:object_id]) banks = @object_type.classify.constantize.where(id: params[:object_id])
course = current_user.manage_courses.find_by!(id: params[:course_id]) course = current_user.manage_courses.find_by!(id: params[:course_id])
task_ids = []
banks.each do |bank| banks.each do |bank|
case @object_type case @object_type
when 'HomeworkBank' # 作业 when 'HomeworkBank' # 作业
quote_homework_bank bank, course task = quote_homework_bank bank, course
when 'ExerciseBank' when 'ExerciseBank'
if bank.container_type == 'Exercise' # 试卷 if bank.container_type == 'Exercise' # 试卷
quote_exercise_bank bank, course task = quote_exercise_bank bank, course
else # 问卷 else # 问卷
quote_poll_bank bank, course task = quote_poll_bank bank, course
end end
when 'GtaskBank' when 'GtaskBank'
quote_gtask_bank bank, course task = quote_gtask_bank bank, course
when 'GtopicBank' when 'GtopicBank'
quote_gtopic_bank bank, course task = quote_gtopic_bank bank, course
end end
task_ids << task.id if task
end end
normal_status("发送成功") render :json => {task_ids: task_ids, status: 0, message: "发送成功"}
end end
def destroy def destroy

@ -84,9 +84,9 @@ export function initAxiosInterceptors(props) {
} }
config.url = `${proxy}${url}`; config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) { if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${'student'}`; config.url = `${config.url}?debug=${debugType}`;
} else { } else {
config.url = `${config.url}&debug=${'student'}`; config.url = `${config.url}&debug=${debugType}`;
} }
} else { } else {
// 加api前缀 // 加api前缀

@ -167,6 +167,11 @@ class CommonWorkSetting extends Component{
} }
on('commonwork_fetch_all', this.fetchAllListener) on('commonwork_fetch_all', this.fetchAllListener)
if(this.props.isAdmin()===true){
this.setState({startEditFlag: true})
}
} }
componentWillUnmount() { componentWillUnmount() {
off('commonwork_fetch_all', this.fetchAllListener) off('commonwork_fetch_all', this.fetchAllListener)

@ -48,7 +48,7 @@ class HomeworkModal extends Component{
if(this.props.starttimes!=undefined&&this.props.starttimes!=""){ if(this.props.starttimes!=undefined&&this.props.starttimes!=""){
this.setState({ this.setState({
endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'months')).format("YYYY-MM-DD HH:mm") endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm")
}) })
} }
} }
@ -70,7 +70,7 @@ class HomeworkModal extends Component{
if(this.props.starttimes!=undefined&&this.props.starttimes!=""){ if(this.props.starttimes!=undefined&&this.props.starttimes!=""){
this.setState({ this.setState({
endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'months')).format("YYYY-MM-DD HH:mm") endtime:moment(moment(handleDateString(this.props.starttimes)).add(1, 'week')).format("YYYY-MM-DD HH:mm")
}) })
} }
} }

@ -6,7 +6,7 @@ import axios from 'axios'
/** /**
角色数组, CREATOR: 创建者, PROFESSOR: 教师, ASSISTANT_PROFESSOR: 助教, STUDENT: 学生 角色数组, CREATOR: 创建者, PROFESSOR: 教师, ASSISTANT_PROFESSOR: 助教, STUDENT: 学生
*/ */
function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSuccess, showNotification }) { function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSuccess, showNotification, getUserId, fetchUser }) {
const [checkBoxRoles, setCheckBoxRoles] = useState(member_roles) const [checkBoxRoles, setCheckBoxRoles] = useState(member_roles)
useEffect(() => { useEffect(() => {
setCheckBoxRoles(member_roles) setCheckBoxRoles(member_roles)
@ -41,7 +41,14 @@ function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSucces
user_id: record.user_id user_id: record.user_id
}) })
if (response.data.status == 0) { if (response.data.status == 0) {
showNotification('保存成功')
onChangeRoleSuccess() onChangeRoleSuccess()
trigger('updatabanner')
if (fetchUser && record.user_id == getUserId) {
fetchUser()
}
} }
console.log(response) console.log(response)
} }

@ -155,6 +155,8 @@ const buildColumns = (that,isParent) => {
member_roles={record.member_roles} member_roles={record.member_roles}
onChangeRoleSuccess={that.onChangeRoleSuccess} onChangeRoleSuccess={that.onChangeRoleSuccess}
showNotification={that.props.showNotification} showNotification={that.props.showNotification}
getUserId={that.props.isUserid}
fetchUser={that.props.fetchUser}
></ChangeRolePop> ></ChangeRolePop>
</React.Fragment> </React.Fragment>
) )
@ -545,6 +547,19 @@ class studentsList extends Component{
addDir = () => { addDir = () => {
trigger('groupAdd', this.props.coursesids) trigger('groupAdd', this.props.coursesids)
} }
addToDir = async () => {
const courseId = this.props.match.params.coursesId
const url = `/courses/${courseId}/join_course_group.json`
const course_group_id = this.props.match.params.course_group_id
const response = await axios.post(url, {
course_group_id
})
if (response && response.data.status == 0) {
this.props.showNotification('加入成功')
this.fetchAll()
}
}
renameDir = () => { renameDir = () => {
const course_group_id = this.props.match.params.course_group_id const course_group_id = this.props.match.params.course_group_id
trigger('groupRename', { id: parseInt(course_group_id), name: this.state.course_group_name}) trigger('groupRename', { id: parseInt(course_group_id), name: this.state.course_group_name})
@ -591,6 +606,7 @@ class studentsList extends Component{
render(){ render(){
const isAdmin = this.props.isAdmin() const isAdmin = this.props.isAdmin()
const isStudent = this.props.isStudent()
const isSuperAdmin = this.props.isSuperAdmin() const isSuperAdmin = this.props.isSuperAdmin()
const isCourseEnd = this.props.isCourseEnd() const isCourseEnd = this.props.isCourseEnd()
let { let {
@ -702,6 +718,8 @@ class studentsList extends Component{
{ {
// pageType !== TYPE_STUDENTS && // pageType !== TYPE_STUDENTS &&
!isCourseEnd && isAdmin && isParent && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>添加分班</WordsBtn> } !isCourseEnd && isAdmin && isParent && <WordsBtn style="blue" className="mr30" onClick={()=>this.addDir()}>添加分班</WordsBtn> }
{
isStudent && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.addToDir()}>加入分班</WordsBtn> }
{ {
isAdmin && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.deleteDir()}>删除分班</WordsBtn> } isAdmin && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.deleteDir()}>删除分班</WordsBtn> }
{ {

@ -165,6 +165,9 @@ function buildColumns(that) {
member_roles={record.member_roles} member_roles={record.member_roles}
onChangeRoleSuccess={that.onChangeRoleSuccess} onChangeRoleSuccess={that.onChangeRoleSuccess}
showNotification={that.props.showNotification} showNotification={that.props.showNotification}
getUserId={that.props.isUserid}
fetchUser={that.props.fetchUser}
></ChangeRolePop> ></ChangeRolePop>
{/* <Popconfirm {/* <Popconfirm
placement="bottom" placement="bottom"
@ -646,6 +649,7 @@ class studentsList extends Component{
combineArray = this.state.application_list combineArray = this.state.application_list
} }
const isAdminOrTeacher = this.props.isAdminOrTeacher() const isAdminOrTeacher = this.props.isAdminOrTeacher()
const isAdminOrCreator = this.props.isAdminOrCreator()
const isSuperAdmin = this.props.isSuperAdmin() const isSuperAdmin = this.props.isSuperAdmin()
const hasGraduationModule = this.hasGraduationModule() const hasGraduationModule = this.hasGraduationModule()
const coursesId = this.props.match.params.coursesId const coursesId = this.props.match.params.coursesId
@ -682,7 +686,7 @@ class studentsList extends Component{
{/* { isAdmin && <WordsBtn style="blue" className="mr30" onClick={()=>this.addTeacher()}></WordsBtn> } {/* { isAdmin && <WordsBtn style="blue" className="mr30" onClick={()=>this.addTeacher()}></WordsBtn> }
{ isAdmin && <WordsBtn style="blue" className="mr30" onClick={()=>this.addStudent()}>添加学生</WordsBtn> } */} { isAdmin && <WordsBtn style="blue" className="mr30" onClick={()=>this.addStudent()}>添加学生</WordsBtn> } */}
{ isAdmin && <WordsBtn style="blue" className="fr" onClick={()=>this.showChangeAdminModal()}>更换管理员</WordsBtn>} { isAdminOrCreator && <WordsBtn style="blue" className="fr" onClick={()=>this.showChangeAdminModal()}>更换管理员</WordsBtn>}
</React.Fragment> </React.Fragment>
} }

Loading…
Cancel
Save