diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb index 17eeab1d6..e920eaa8a 100644 --- a/app/controllers/attendances_controller.rb +++ b/app/controllers/attendances_controller.rb @@ -11,6 +11,16 @@ class AttendancesController < ApplicationController if params[:history] @attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") + if @user_course_identity == Course::STUDENT + member = @course.students.find_by(user_id: current_user.id) + group_ids = [member&.course_group_id.to_i, 0] + @attendances = @attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: group_ids}) + + attendance_ids = @attendances.pluck(:id) + @normal_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "NORMAL").size + @leave_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "LEAVE").size + @absence_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "ABSENCE").size + end else @attendances = @course.course_attendances.where("attendance_date > '#{current_date}' or (attendance_date = '#{current_date}' and end_time > '#{current_end_time}')") @@ -21,6 +31,10 @@ class AttendancesController < ApplicationController @attendances = paginate @attendances.includes(:user, :course_member_attendances) end + def statistics + + end + def history_attendances current_date = Date.current current_end_time = Time.current.strftime("%H:%M:%S") diff --git a/app/controllers/course_second_categories_controller.rb b/app/controllers/course_second_categories_controller.rb index 62cbf83d9..c59ffbdbe 100644 --- a/app/controllers/course_second_categories_controller.rb +++ b/app/controllers/course_second_categories_controller.rb @@ -43,6 +43,12 @@ class CourseSecondCategoriesController < ApplicationController elsif @course_module.module_type == "video" @course.course_videos.where(course_second_category_id: @category.id).update_all(course_second_category_id: 0) @right_url = "/classrooms/#{@course.id}/course_videos" + elsif @course_module.module_type == "common_homework" + @category.homework_commons.update_all(course_second_category_id: 0) + @right_url = "/classrooms/#{@course.id}/common_homeworks/#{@course_module.id}" + elsif @course_module.module_type == "group_homework" + @category.homework_commons.update_all(course_second_category_id: 0) + @right_url = "/classrooms/#{@course.id}/group_homeworks/#{@course_module.id}" end @category.destroy diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 42d7f3499..38aa2812a 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -75,7 +75,7 @@ class Challenge < ApplicationRecord if identifier.present? shixun.task_pass || self.status != 3 ? "/tasks/#{identifier}" : "" else - self.position == 1 ? "/api/shixuns/#{shixun.identifier}/shixun_exec" : "" + self.position == 1 ? "/shixuns/#{shixun.identifier}/shixun_exec.json" : "" end end diff --git a/app/views/attendances/index.json.jbuilder b/app/views/attendances/index.json.jbuilder index 76febf51e..8a4dd2bb1 100644 --- a/app/views/attendances/index.json.jbuilder +++ b/app/views/attendances/index.json.jbuilder @@ -10,9 +10,15 @@ json.attendances @attendances do |attendance| json.end_time attendance.end_time.strftime("%H:%M") json.edit_auth @user_course_identity < Course::PROFESSOR || attendance.user_id == User.current.id - if @user_course_identity < Course::PROFESSOR == Course::STUDENT + if @user_course_identity == Course::STUDENT json.attendance_status student_attendance_status(attendance, User.current) end end -json.attendances_count @attendances_count \ No newline at end of file +json.attendances_count @attendances_count + +if @user_course_identity == Course::STUDENT + json.normal_count @normal_count + json.leave_count @leave_count + json.absence_count @absence_count +end \ No newline at end of file diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js index 0e701c00c..32263676f 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js @@ -33,7 +33,7 @@ class Challenges extends Component { isSpin:false, boxoffsetHeigh:0, opentitletype:true, - isopentitletype:"Less", + isopentitletype:"Less" } } @@ -357,6 +357,50 @@ class Challenges extends Component { }) } + // 开启挑战 + beginChallenge=(url)=>{ + if (this.props.checkIfLogin() === false) { + this.props.showLoginDialog() + return; + } + if (this.props.checkIfProfileCompleted() === false) { + this.setState({ + AccountProfiletype: true + }) + return; + } + this.setState({ + startbtns:true + }) + if(url.indexOf(".json")>-1){ + axios.get(url).then((response) => { + if (response.data.status === -2) { + this.setState({ + startbtns:false, + shixunsreplace:true, + hidestartshixunsreplacevalue:response.data.message+".json" + }) + } else if (response.data.status === -1) { + this.setState({ + startbtns: false + }) + }else if(response.data.status===-3){ + this.setState({ + shixunsmessage:response.data.message, + startshixunCombattype:true, + startbtns:false + }) + } else { + window.location.href = "/tasks/" + response.data.game_identifier; + } + }).catch((error) => { + + }); + }else{ + window.location.href=url; + } + } + render() { let { ChallengesDataList, startbtns, sumidtype ,startshixunCombattype,shixunsreplace,shixunsmessage,hidestartshixunsreplacevalue,operationstrue,AccountProfiletype} = this.state; let { loadingContent } = this.props; @@ -700,49 +744,60 @@ class Challenges extends Component { +