diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 54c07d1c1..5ba0db363 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -451,7 +451,7 @@ class ApplicationController < ActionController::Base cpu_limit = config.cpu_limit.presence || 1 cpu_request = config.lower_cpu_limit.presence || 0.1 memory_limit = config.memory_limit.presence || 1024 - request_limit = config.resource_limit.presence || 10 + request_limit = config.request_limit.presence || 10 resource_limit = config.resource_limit.presence || 10000 container << {:image => mirror.name, :cpuLimit => cpu_limit, diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 5c3f2e743..14276b4dd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -41,7 +41,6 @@ class CoursesController < ApplicationController before_action :find_board, only: :board_list before_action :validate_page_size, only: :mine before_action :course_tasks, only: [:tasks_list, :update_task_position] - before_action :find_container, only: [:update_task_position] if RUBY_PLATFORM =~ /linux/ require 'simple_xlsx_reader' @@ -62,6 +61,9 @@ class CoursesController < ApplicationController @courses = Course.where(is_delete: 0, is_hidden: 0, is_end: 0) end + # 金课未开课的不显示在首页 + @courses = @courses.where("start_date is null or start_date <= '#{Date.today}'") + # 根据搜索关键字进一步筛选 if params[:search].present? # REDO:Extension @@ -1150,17 +1152,20 @@ class CoursesController < ApplicationController end def update_task_position - tip_exception("缺少position参数") if params[:position].blank? - unless params[:position].to_i == @task.position - if params[:position].to_i < @task.position - @tasks.where("position < #{@task.position} and position >= ?", params[:position]).update_all("position = position + 1") - else - @tasks.where("position > #{@task.position} and position <= ?", params[:position]).update_all("position = position - 1") + Rails.logger.info("#######task_ids_length#{params[:task_ids].uniq.length}#########task_count:#{@tasks.count}") + tip_exception("task_ids参数有误") if params[:task_ids].blank? || params[:task_ids].uniq.length != @tasks.count + ActiveRecord::Base.transaction do + begin + @tasks.each do |task| + position = params[:task_ids].reverse.index(task.id).to_i + 1 + task.update_attributes!(position: position) + end + normal_status(0, "移动成功") + rescue Exception => e + uid_logger(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback end - @task.update_attributes(position: params[:position]) - normal_status(0, "移动成功") - else - normal_status(-1, "位置没有变化") end end @@ -1199,8 +1204,8 @@ class CoursesController < ApplicationController def validate_start_end_date prev_course = @subject.courses.where("id < #{@course.id}").last next_course = @subject.courses.where("id > #{@course.id}").first - tip_exception("开始时间和结束时间不能与其他期开课时间重叠") if prev_course && params[:start_date] <= strf_date(prev_course.end_date) - tip_exception("开始时间和结束时间不能与其他期开课时间重叠") if next_course && params[:end_date] >= strf_date(next_course.start_date) + tip_exception("开始时间不能与往期开课时间重叠") if prev_course && params[:start_date] <= strf_date(prev_course.end_date) + tip_exception("结束时间不能与后期开课时间重叠") if next_course && params[:end_date] >= strf_date(next_course.start_date) end # 超级管理员和课堂管理员的权限判断 @@ -1247,24 +1252,24 @@ class CoursesController < ApplicationController end end - def find_container - case params[:container_type] - when 'shixun_homework', 'common_homework', 'group_homework' - @task = HomeworkCommon.find_by(id: params[:container_id]) - when 'exercise' - @task = Exercise.find_by(id: params[:container_id]) - when 'poll' - @task = Poll.find_by(id: params[:container_id]) - when 'graduation_topic' - @task = GraduationTopic.find_by(id: params[:container_id]) - when 'graduation_task' - @task = GraduationTask.find_by(id: params[:container_id]) - when 'attachment' - @task = Attachment.find_by(id: params[:container_id]) - else - tip_exception("container_type参数有误") - end - end + # def find_container + # case params[:container_type] + # when 'shixun_homework', 'common_homework', 'group_homework' + # @task = HomeworkCommon.find_by(id: params[:container_id]) + # when 'exercise' + # @task = Exercise.find_by(id: params[:container_id]) + # when 'poll' + # @task = Poll.find_by(id: params[:container_id]) + # when 'graduation_topic' + # @task = GraduationTopic.find_by(id: params[:container_id]) + # when 'graduation_task' + # @task = GraduationTask.find_by(id: params[:container_id]) + # when 'attachment' + # @task = Attachment.find_by(id: params[:container_id]) + # else + # tip_exception("container_type参数有误") + # end + # end def student_act_score group_id, search sql_select = %Q{SELECT cm.*,( diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb index a21614efc..78be3b8f9 100644 --- a/app/services/homeworks_service.rb +++ b/app/services/homeworks_service.rb @@ -9,6 +9,7 @@ class HomeworksService homework_detail_manual = HomeworkDetailManual.new homework.homework_detail_manual = homework_detail_manual + homework.position = course.practice_homeworks.first&.position.to_i + 1 if homework.save! homework_detail_manual.save! if homework_detail_manual diff --git a/db/migrate/20190820021047_migrate_course_task_position.rb b/db/migrate/20190820021047_migrate_course_task_position.rb index cf1b633bd..f32ac88b1 100644 --- a/db/migrate/20190820021047_migrate_course_task_position.rb +++ b/db/migrate/20190820021047_migrate_course_task_position.rb @@ -1,13 +1,5 @@ class MigrateCourseTaskPosition < ActiveRecord::Migration[5.2] def change add_column :homework_commons, :position, :integer, :default => 0 - - Course.find_each do |course| - puts course.id - course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC, - homework_commons.created_at DESC").reverse.each_with_index do |homework, index| - homework.update_columns(position: index + 1) - end - end end end diff --git a/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb b/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb new file mode 100644 index 000000000..9a19b12e3 --- /dev/null +++ b/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb @@ -0,0 +1,11 @@ +class MigrateCourseShixunHomeworkPosition < ActiveRecord::Migration[5.2] + def change + Course.find_each do |course| + puts course.id + course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC, + homework_commons.created_at DESC").reverse.each_with_index do |homework, index| + homework.update_columns(position: index + 1) + end + end + end +end diff --git a/public/react/src/App.js b/public/react/src/App.js index 9621fdc18..ab3ebb02d 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -19,7 +19,6 @@ import Trialapplicationysl from './modules/login/Trialapplicationysl'; import Trialapplicationreview from './modules/user/Trialapplicationreview'; import Addcourses from "./modules/courses/coursesPublic/Addcourses"; import AccountProfile from "./modules/user/AccountProfile"; -import Certifiedprofessional from "./modules/modals/Certifiedprofessional" import Trialapplication from './modules/login/Trialapplication' import NotFoundPage from './NotFoundPage' @@ -306,7 +305,7 @@ class App extends Component { - + {/**/} diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js index 8c77aaab2..65cda33a9 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js @@ -307,11 +307,15 @@ class CommonWorkDetailIndex extends Component{ onClick={() => this.setState({moduleName: '参考答案'})} className={`${childModuleName == '参考答案' ? 'active' : '' } `} to={`/courses/${courseId}/${moduleEngName}/${workId}/answer`}>参考答案} + + {this.props.isAdmin() ? this.setState({moduleName: '设置'})} className={`${childModuleName == '设置' ? 'active' : '' } `} style={{paddingLeft:'38px'}} - to={`/courses/${courseId}/${moduleEngName}/${workId}/setting`}>设置 + to={`/courses/${courseId}/${moduleEngName}/${workId}/setting`}>设置: + "" + } {/* { this.props.tabRightComponents } */} diff --git a/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js b/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js index 56460a44a..a092c5066 100644 --- a/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js +++ b/public/react/src/modules/courses/busyWork/common/WorkDetailPageHeader.js @@ -144,10 +144,13 @@ class WorkDetailPageHeader extends Component{ {view_answer == true && 参考答案} + {this.props.isAdmin()? 设置 + to={`/courses/${courseId}/${moduleEngName}/${workId}/setting`}>设置: + "" + } { this.props.tabRightComponents } diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index 8947cf718..efc30ee2e 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -12,6 +12,7 @@ import Guide from './CoursesGuide'; import AddStudentModal from '../members/modal/AddStudentModal' import AddTeacherModal from '../members/modal/AddTeacherModal' import Jointheclass from '../../modals/Jointheclass' +import Certifiedprofessional from "../../modals/Certifiedprofessional"; // 点击按钮复制功能 // function jsCopy(){ // var e = document.getElementById("copy_invite_code"); @@ -48,6 +49,8 @@ class CoursesBanner extends Component { is_guide:false, excellent:false,//是否是精品课堂 yslJointhe:false, + mydisplay:false + } } componentDidMount() { @@ -58,9 +61,22 @@ class CoursesBanner extends Component { componentWillUnmount() { off('updatabanner', this.updatabanner) } - - onloadupdatabanner=()=>{ + HideAddcoursestypess=(i)=>{ + console.log("调用了"); + this.setState({ + Addcoursestypes:false, + mydisplay:true, + occupation:i, + }) + }; + ModalCancelsy=()=>{ + this.setState({ + mydisplay:false, + }) + }; + + onloadupdatabanner=()=>{ this.updatabanner() } updatabanner=()=>{ @@ -413,7 +429,9 @@ class CoursesBanner extends Component { {Addcoursestypes === true ? this.tojoinclass(2)} + HideAddcoursestypess={(i)=>this.HideAddcoursestypess(i)} /> : ""} + - {excellent===false? + {/*{excellent===false?*/} + {/* :*/} + {/*
*/} + {/* */} + {/* /!*coursedata.course_identity === 6 是非课堂成员*!/*/} + {/* {coursedata.course_identity === 6&&coursedata.educoder_teacher===false?*/} + {/* this.myyslgradin()}>加入课堂: ""}*/} + + {/* {coursedata.course_identity === 6&&coursedata.educoder_teacher===true?*/} + {/* this.myyslgradin()}>加入课堂: ""}*/} + + {/* /!*{this.props.isStudent()? this.exitclass()}*!/*/} + {/* /!*> 退出课堂 :""}*!/*/} + {/*
*/} + + {/*}*/}
{coursedata.switch_to_student === true ? 退出课堂 :""}
- : -
- - {/*coursedata.course_identity === 6 是非课堂成员*/} - {coursedata.course_identity === 6&&coursedata.educoder_teacher===false? - this.myyslgradin()}>加入课堂: ""} - - {coursedata.course_identity === 6&&coursedata.educoder_teacher===true? - this.myyslgradin()}>加入课堂: ""} - - {/*{this.props.isStudent()? this.exitclass()}*/} - {/*> 退出课堂 :""}*/} -
- } :""} + {this.props.isAdmin() ? this.ChangeTab(3)} - >设置 + >设置:""} {/*{this.props.isAdmin() ? { - if (response != undefined) - if (response && response.data.status === -1) { - if(response.data.message==="该课堂要求成员完成实名认证"){ - this.setState({ - mydisplay:true, - occupation:1, - }) - - }else if(response.data.message==="该课堂要求成员完成职业认证"){ - this.setState({ - mydisplay:true, - occupation:2, - }) - }else if(response.data.message==="该课堂要求成员完成实名和职业认证"){ - this.setState({ - mydisplay:true, - occupation:3, - }) - } - } - return response; - }, (error) => { - //TODO 这里如果样式变了会出现css不加载的情况 - - }); + // axios.interceptors.response.use((response) => { + // if (response != undefined) + // if (response && response.data.status === -1) { + // + // } + // return response; + // }, (error) => { + // //TODO 这里如果样式变了会出现css不加载的情况 + // + // }); } modalCancel=()=>{ - this.setState({ - mydisplay:false, - }) + this.props.ModalCancelsy(); }; setDownload=()=>{ @@ -63,7 +45,7 @@ class Certifiedprofessional extends Component { render() { // console.log("加入金品课堂2"); // console.log(this.props); - let{occupation} =this.state; + let{occupation} =this.props; return( diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index dff749515..66a120716 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -3,6 +3,7 @@ import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import { Redirect } from 'react-router'; import AccountProfile from"../user/AccountProfile"; import PropTypes from 'prop-types'; +import Certifiedprofessional from "../../modules/modals/Certifiedprofessional" // import searchImg from '../../../../images/educoder/icon/search.svg' @@ -62,7 +63,9 @@ class NewHeader extends Component { isRender:false, showSearchOpentype:false, showTrial:false, - setevaluatinghides:false + setevaluatinghides:false, + occupation:0, + mydisplay:false } // console.log("176") // console.log(props); @@ -95,7 +98,29 @@ class NewHeader extends Component { //获取游览器地址 window.sessionStorage.setItem("yslgeturls",JSON.stringify(window.location.href)) - + // axios.interceptors.response.use((response) => { + // if (response != undefined) + // if (response && response.data.status === -1) { + // if (response.data.message === "该课堂要求成员完成实名认证") { + // + // } else if (response.data.message === "该课堂要求成员完成职业认证") { + // console.log("该课堂要求成员完成职业认证"); + // this.HideAddcoursestypess(2); + // + // + // + // return + // } else if (response.data.message === "该课堂要求成员完成实名和职业认证") { + // console.log("该课堂要求成员完成实名和职业认证"); + // this.HideAddcoursestypess(3); + // return + // + // } + // } + // return response; + // }, (error) => { + // + // }); } componentDidUpdate = (prevProps) => { @@ -326,7 +351,20 @@ class NewHeader extends Component { this.setState({ Addcoursestypes:false }) - } + }; + HideAddcoursestypess=(i)=>{ + console.log("调用了"); + this.setState({ + Addcoursestypes:false, + mydisplay:true, + occupation:i, + }) + }; + ModalCancelsy=()=>{ + this.setState({ + mydisplay:false, + }) + }; hidetojoinclass=()=>{ @@ -880,7 +918,10 @@ submittojoinclass=(value)=>{ {Addcoursestypes===true?this.HideAddcoursestypess(i)} />:""} + + {/* /courses/join_course_multi_role */}