dev_hs
杨树明 6 years ago
commit 09df772c2f

@ -26,18 +26,22 @@ class CoursesController < ApplicationController
:base_info, :get_historical_courses, :create_group_by_importing_file, :base_info, :get_historical_courses, :create_group_by_importing_file,
:attahcment_category_list,:export_member_scores_excel, :duplicate_course, :attahcment_category_list,:export_member_scores_excel, :duplicate_course,
:switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course,
:informs, :update_informs, :join_excellent_course, :online_learning] :informs, :update_informs, :join_excellent_course, :online_learning,
:update_task_position, :tasks_list]
before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate,
:transfer_to_course_group, :delete_from_course, :transfer_to_course_group, :delete_from_course,
:search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher] :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher]
before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin, before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin,
:set_course_group, :create_group_by_importing_file, :update_informs] :set_course_group, :create_group_by_importing_file, :update_informs,
:update_task_position, :tasks_list]
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group, before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
:change_course_teacher, :export_member_scores_excel, :course_group_list, :change_course_teacher, :export_member_scores_excel, :course_group_list,
:teacher_application_review, :apply_teachers, :delete_course_teacher] :teacher_application_review, :apply_teachers, :delete_course_teacher]
before_action :validate_course_name, only: [:create, :update] before_action :validate_course_name, only: [:create, :update]
before_action :find_board, only: :board_list before_action :find_board, only: :board_list
before_action :validate_page_size, only: :mine 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/ if RUBY_PLATFORM =~ /linux/
require 'simple_xlsx_reader' require 'simple_xlsx_reader'
@ -100,7 +104,12 @@ class CoursesController < ApplicationController
# GET /courses/new # GET /courses/new
def new def new
@course = Course.new @course = Course.new
normal_status("成功") unless params[:subject_id].blank?
subject = Subject.find_by(id: params[:subject_id], excellent: 1)
render :json => {status: 0, course_name: "#{subject&.name}#{subject&.courses&.count.to_i + 1}"}
else
normal_status("成功")
end
end end
# Get /courses/:id/settings # Get /courses/:id/settings
@ -906,15 +915,17 @@ class CoursesController < ApplicationController
# 邀请码验证 # 邀请码验证
return normal_status(-1, "邀请码不能为空") if params[:invite_code].blank? return normal_status(-1, "邀请码不能为空") if params[:invite_code].blank?
invite_code = params[:invite_code] invite_code = params[:invite_code]
course = Course.find_by(invite_code: invite_code, is_delete: 0, invite_code_halt: 0, is_end: 0) course = Course.find_by(invite_code: invite_code, is_delete: 0, invite_code_halt: 0)
course_group = CourseGroup.find_by(invite_code: invite_code) course_group = CourseGroup.find_by(invite_code: invite_code)
if course.blank? if course.blank?
return normal_status(-1, "邀请码无效") if course_group.blank? return normal_status(-1, "邀请码无效") if course_group.blank?
course = Course.find_by(id: course_group.course_id, is_delete: 0, invite_code_halt: 0, is_end: 0) course = Course.find_by(id: course_group.course_id, is_delete: 0, invite_code_halt: 0)
return normal_status(-1, "邀请码无效") if course.blank? return normal_status(-1, "邀请码无效") if course.blank?
end end
return normal_status(-1, "课堂已结束,无法加入") if course.is_end
# 实名认证和职业认证的身份判断 # 实名认证和职业认证的身份判断
return normal_status(-1, "该课堂要求成员完成实名和职业认证") if course.authentication && return normal_status(-1, "该课堂要求成员完成实名和职业认证") if course.authentication &&
course.professional_certification && (!current_user.authentication || !current_user.professional_certification) course.professional_certification && (!current_user.authentication || !current_user.professional_certification)
@ -1115,6 +1126,44 @@ class CoursesController < ApplicationController
render_ok(count: count, courses: courses.select(:id, :name).as_json) render_ok(count: count, courses: courses.select(:id, :name).as_json)
end end
def tasks_list
case params[:container_type]
when 'shixun_homework'
@tasks = @course.practice_homeworks
when 'common_homework'
@tasks = @course.normal_homeworks
when 'group_homework'
@tasks = @course.group_homeworks
when 'exercise'
@tasks = @course.exercises
when 'poll'
@tasks = @course.polls
when 'graduation_topic'
@tasks = @course.graduation_topics
when 'graduation_task'
@tasks = @course.graduation_tasks
when 'attachment'
@tasks = @course.attachments
else
tip_exception("请指定任务类型")
end
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")
end
@task.update_attributes(position: params[:position])
normal_status(0, "移动成功")
else
normal_status(-1, "位置没有变化")
end
end
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
@ -1175,6 +1224,48 @@ class CoursesController < ApplicationController
end end
end end
def course_tasks
case params[:container_type]
when 'shixun_homework'
@tasks = @course.practice_homeworks
when 'common_homework'
@tasks = @course.normal_homeworks
when 'group_homework'
@tasks = @course.group_homeworks
when 'exercise'
@tasks = @course.exercises
when 'poll'
@tasks = @course.polls
when 'graduation_topic'
@tasks = @course.graduation_topics
when 'graduation_task'
@tasks = @course.graduation_tasks
when 'attachment'
@tasks = @course.attachments
else
tip_exception("请指定任务类型")
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 def student_act_score group_id, search
sql_select = %Q{SELECT cm.*,( sql_select = %Q{SELECT cm.*,(
SELECT SUM(student_works.work_score) SELECT SUM(student_works.work_score)

@ -37,8 +37,6 @@ class HomeworkCommonsController < ApplicationController
@category = @main_category.course_second_categories.find_by(id: params[:category]) @category = @main_category.course_second_categories.find_by(id: params[:category])
tip_exception("子目录id有误") if !@category.present? tip_exception("子目录id有误") if !@category.present?
@homework_commons = @homework_commons.where(course_second_category_id: params[:category]) @homework_commons = @homework_commons.where(course_second_category_id: params[:category])
elsif @homework_type == 4
@homework_commons = @homework_commons
end end
@all_count = @homework_commons.size @all_count = @homework_commons.size

@ -32,7 +32,12 @@ class Course < ApplicationRecord
has_many :teacher_course_members, -> { teachers_and_admin }, class_name: 'CourseMember' has_many :teacher_course_members, -> { teachers_and_admin }, class_name: 'CourseMember'
has_many :teacher_users, through: :teacher_course_members, source: :user has_many :teacher_users, through: :teacher_course_members, source: :user
has_many :course_messages, dependent: :destroy has_many :course_messages, dependent: :destroy
has_many :homework_commons, dependent: :destroy has_many :homework_commons, dependent: :destroy
has_many :normal_homeworks, -> { normals }, class_name: 'HomeworkCommon'
has_many :group_homeworks, -> { groups }, class_name: 'HomeworkCommon'
has_many :practice_homeworks, -> { practices }, class_name: 'HomeworkCommon'
has_many :homework_group_settings has_many :homework_group_settings
has_many :graduation_works, dependent: :destroy has_many :graduation_works, dependent: :destroy

@ -12,6 +12,7 @@ class HomeworkCommon < ApplicationRecord
belongs_to :course, counter_cache: true belongs_to :course, counter_cache: true
belongs_to :homework_bank, optional: true belongs_to :homework_bank, optional: true
belongs_to :user
has_many :homework_challenge_settings, dependent: :destroy has_many :homework_challenge_settings, dependent: :destroy
has_one :homework_commons_shixun, dependent: :destroy has_one :homework_commons_shixun, dependent: :destroy
@ -48,6 +49,9 @@ class HomeworkCommon < ApplicationRecord
scope :search_homework_type, lambda {|num| where(homework_type:num)} scope :search_homework_type, lambda {|num| where(homework_type:num)}
scope :unified_setting, -> {where("unified_setting = ? ", 1)} scope :unified_setting, -> {where("unified_setting = ? ", 1)}
scope :normals, -> {where(homework_type: %i[normal]).order("position desc")}
scope :groups, -> {where(homework_type: %i[group]).order("position desc")}
scope :practices, -> {where(homework_type: %i[practice]).order("position desc")}
# 是否显示参考答案 # 是否显示参考答案
def view_answer identity, user_id def view_answer identity, user_id

@ -0,0 +1,7 @@
json.tasks @tasks.each do |task|
json.user_name task.user.real_name
json.task_id task.id
json.task_name task.name
json.category task.course_second_category&.name
json.position task.position
end

@ -352,6 +352,8 @@ Rails.application.routes.draw do
post 'update_informs' post 'update_informs'
get 'online_learning' get 'online_learning'
post 'join_excellent_course' post 'join_excellent_course'
get 'tasks_list'
post 'update_task_position'
end end
collection do collection do

@ -0,0 +1,13 @@
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

@ -19,6 +19,7 @@ import Trialapplicationysl from './modules/login/Trialapplicationysl';
import Trialapplicationreview from './modules/user/Trialapplicationreview'; import Trialapplicationreview from './modules/user/Trialapplicationreview';
import Addcourses from "./modules/courses/coursesPublic/Addcourses"; import Addcourses from "./modules/courses/coursesPublic/Addcourses";
import AccountProfile from "./modules/user/AccountProfile"; import AccountProfile from "./modules/user/AccountProfile";
import Certifiedprofessional from "./modules/modals/Certifiedprofessional"
import Trialapplication from './modules/login/Trialapplication' import Trialapplication from './modules/login/Trialapplication'
import NotFoundPage from './NotFoundPage' import NotFoundPage from './NotFoundPage'
@ -305,7 +306,7 @@ class App extends Component {
<Trialapplicationreview {...this.props} {...this.state}></Trialapplicationreview> <Trialapplicationreview {...this.props} {...this.state}></Trialapplicationreview>
<Addcourses {...this.props} {...this.state}/> <Addcourses {...this.props} {...this.state}/>
<AccountProfile {...this.props} {...this.state}/> <AccountProfile {...this.props} {...this.state}/>
{/*<Certifiedprofessional {...this.props} {...this.state} />*/}
<Router> <Router>
<Switch> <Switch>

@ -213,7 +213,13 @@ class Addcourses extends Component{
student:student student:student
} }
).then((response) => { ).then((response) => {
console.log(217);
console.log(response);
if(response === undefined){ if(response === undefined){
this.setState({
Addcoursestype:false,
isSpin:false
});
return return
} }
if(response.data.status===0){ if(response.data.status===0){
@ -254,7 +260,7 @@ class Addcourses extends Component{
}); });
this.setState({ this.setState({
Addcoursestype:false Addcoursestype:false
}) });
if(Addcoursestype===true){ if(Addcoursestype===true){
this.props.hideAddcoursestype(); this.props.hideAddcoursestype();
} }
@ -273,7 +279,8 @@ class Addcourses extends Component{
isSpin:false isSpin:false
}) })
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error);
console.log("报错了报错报错了");
this.setState({ this.setState({
isSpin:false isSpin:false
}) })

@ -1182,7 +1182,7 @@ class Studentshavecompletedthelist extends Component {
}) })
} }
this.Searchdatasys(this.state.order, this.state.commit_status, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, pageNumber, 20); this.Searchdatasys(this.state.order, this.state.course_groupyslstwo, this.state.review, this.state.checkedValuesineinfo, this.state.searchtext, pageNumber, 20);
} }
paginationonChanges = (pageNumber) => { paginationonChanges = (pageNumber) => {

@ -169,10 +169,12 @@ class Goldsubject extends Component {
// console.log(user_school); // console.log(user_school);
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
school:user_school, school:user_school,
starttime:moment(new Date(),dateFormat),
}); });
this.setState({ this.setState({
school:user_school, school:user_school,
Whethertocreateanewclassroom:true, Whethertocreateanewclassroom:true,
datatimetwo: moment(new Date(),dateFormat),
}); });
this.handleSearchschool(user_school); this.handleSearchschool(user_school);
} }
@ -830,7 +832,7 @@ class Goldsubject extends Component {
{getFieldDecorator("checkboxgroup", { {getFieldDecorator("checkboxgroup", {
initialValue: [ initialValue: [
"announcement","online_learning","shixun_homework", "exercise", "announcement","online_learning","shixun_homework","common_homework",
], ],
})( })(
<Checkbox.Group style={{width: "800px", marginTop: "10px"}}> <Checkbox.Group style={{width: "800px", marginTop: "10px"}}>

@ -1,6 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Modal} from 'antd'; import { Modal} from 'antd';
import axios from 'axios'; import axios from 'axios';
import certfed from './certfed.css';
//认证职业 //认证职业
class Certifiedprofessional extends Component { class Certifiedprofessional extends Component {
@ -70,12 +71,24 @@ class Certifiedprofessional extends Component {
centered={true} centered={true}
visible={this.state.mydisplay} visible={this.state.mydisplay}
width="600px" width="600px"
heigth="307px"
> >
<div className="educouddiv"> <div className="educouddiv">
<div className={"tabeltext-alignleft"}><p style={{fontSize: "16px",marginTop:"46px"}}>请在完成条件后重试</p></div> <div className={"tabeltext-alignleft fontsizecoirlysl"}><p style={{fontSize: "16px",marginTop:"26px"}}>请在完成条件后重试</p></div>
<div className="clearfix edu-txt-center" style={{marginTop:"98px"}}> <div className="yslcentercerlfed edu-txt-center mt30" >
<div className="mr30">
<span className="fontsizecoirlysltwo">未实名认证</span>
</div>
<div >
<span className="fontsizecoirlysltwo">未职业认证</span>
</div>
</div>
<div className="clearfix edu-txt-center mt60">
<a className="task-btn mr30" onClick={()=>this.modalCancel()}>取消</a> <a className="task-btn mr30" onClick={()=>this.modalCancel()}>取消</a>
<a className="task-btn task-btn-orange" onClick={()=>this.setDownload()}>确认</a> <a className="task-btn task-btn-orange" onClick={()=>this.setDownload()}>立即认证</a>
</div> </div>
</div> </div>
</Modal> </Modal>

@ -0,0 +1,21 @@
.yslcenter
{
display: flex;
justify-content:center;
display: flex;
flex-direction:column;
}
.yslcentercerlfed
{ display: flex;
justify-content:center;
display: flex;
flex-direction:row;
}
.fontsizecoirlysl{
color: #333333;
font-size: 16px;
}
.fontsizecoirlysltwo{
font-size: 14px;
color: #979797;
}
Loading…
Cancel
Save