diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15e795bdb..fa4648852 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 3117 end diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 57e1e10df..19823d42b 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -62,11 +62,11 @@ class Weapps::AttendancesController < ApplicationController where("attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}'") @history_count = @history_attendances.size - # 当前签到如果存在快捷签到,则直接签到 - quick_attendances = @current_attendances.where(mode: "QUICK") - if quick_attendances.present? - student_direct_attendance quick_attendances, member - end + # 当前签到如果存在快捷签到,则直接签到(不在这里处理) + # quick_attendances = @current_attendances.where(mode: "QUICK") + # if quick_attendances.present? + # student_direct_attendance quick_attendances, member + # end student_attendance_ids = @history_attendances.pluck(:id) student_attendance_ids += @current_attendances.present? ? @current_attendances.pluck(:id) : [] diff --git a/app/controllers/weapps/course_member_attendances_controller.rb b/app/controllers/weapps/course_member_attendances_controller.rb index 7e315fc85..5e92d5928 100644 --- a/app/controllers/weapps/course_member_attendances_controller.rb +++ b/app/controllers/weapps/course_member_attendances_controller.rb @@ -28,19 +28,24 @@ class Weapps::CourseMemberAttendancesController < ApplicationController end def create - tip_exception("签到码不能为空") if params[:code].blank? - tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE"].include?(params[:attendance_mode]) + tip_exception("签到码不能为空") if params[:attendance_mode] != "QUICK" && params[:code].blank? + tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE", "QUICK"].include?(params[:attendance_mode]) - attendance = CourseAttendance.find_by(attendance_code: params[:code]) - tip_exception("签到码输入有误") if attendance.blank? || attendance.course.blank? + if params[:attendance_mode] == "QUICK" + attendance = CourseAttendance.find_by(id: params[:attendance_id]) + else + attendance = CourseAttendance.find_by(attendance_code: params[:code]) + end + tip_exception("该签到不存在") if attendance.blank? || attendance.course.blank? member = attendance.course.students.find_by(user_id: current_user.id) - tip_exception("签到码输入有误") if member.blank? + tip_exception("该签到不存在") if member.blank? tip_exception("不在签到时间内") unless attendance.current_attendance? - tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] == "QRCODE" - tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] == "NUMBER" + tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] != "NUMBER" + tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] != "QRCODE" + tip_exception("只支持快捷签到") if attendance.mode == "QUICK" && params[:attendance_mode] != "QUICK" current_attendance = attendance.course_member_attendances.find_by(user_id: current_user.id) if current_attendance.present? diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index fb4afd436..8a21e76da 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -10,7 +10,7 @@ import { CNotificationHOC } from './common/CNotificationHOC' import {ImageLayerOfCommentHOC} from '../page/layers/ImageLayerOfCommentHOC' import "./css/Courses.css" //引入对应跳转的组件 - +//里面有资源 const ListPageIndex = Loadable({ loader: () => import('./ListPageIndex'), loading:Loading, @@ -964,4 +964,4 @@ class CoursesIndex extends Component{ } } -export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); \ No newline at end of file +export default withRouter(ImageLayerOfCommentHOC({imgSelector: '.imageLayerParent img, .imageLayerParent .imageTarget', parentSelector: '.newMain'}) (CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(CoursesIndex) )))); diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 53f607b2e..37dd95298 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -1,6 +1,6 @@ -import React,{ Component } from "react"; -import { WordsBtn } from 'educoder'; -import {Tooltip,message} from 'antd'; +import React, {Component} from "react"; +import {WordsBtn} from 'educoder'; +import {Tooltip, message} from 'antd'; import {Link} from 'react-router-dom'; import {getImageUrl} from 'educoder'; import axios from 'axios' @@ -10,25 +10,40 @@ import CoursesListType from '../coursesPublic/CoursesListType'; import Showoldfiles from "../coursesPublic/Showoldfiles"; import Modals from '../../modals/Modals'; -class Fileslistitem extends Component{ - constructor(props){ +class Fileslistitem extends Component { + constructor(props) { super(props); - this.state = { - - } + this.state = {} } - settingList=()=>{ - let {discussMessage}=this.props + settingList = (bools) => { + let {discussMessage} = this.props this.setState({ - discussMessageid:discussMessage.id + discussMessageid: discussMessage.id }) - this.props.Settingtypes(discussMessage.id) - } + if (bools === true) { + this.props.Settingtypes(discussMessage.id) + } else { + this.props.Settingtypess(discussMessage.id) + } - showfiles=(list)=>{ - if(this.props.checkIfLogin()===false){ + } + //外链 + showfiless = (url,id) => { + window.open(url) + let urls=`/files/${id}/update_visits.json`; + axios.post(urls,{ + }).then((result)=>{ + if(result.data.status===0){ + this.props.Updateresourcepage() + }else{ + this.props.showNotification(result.data.message); + } + }) + } + showfiles = (list) => { + if (this.props.checkIfLogin() === false) { this.props.showLoginDialog() return } @@ -43,21 +58,21 @@ class Fileslistitem extends Component{ // return // } - if(list.is_history_file===false){ + if (list.is_history_file === false) { // this.props.DownloadFileA(list.title,list.url) //window.location.href=list.url; window.open(list.url, '_blank'); - }else{ - let {discussMessage,coursesId}=this.props - let file_id=discussMessage.id - let url="/files/"+file_id+"/histories.json" - axios.get(url,{ - params:{ - course_id:coursesId + } else { + let {discussMessage, coursesId} = this.props + let file_id = discussMessage.id + let url = "/files/" + file_id + "/histories.json" + axios.get(url, { + params: { + course_id: coursesId }, - }).then((result)=>{ + }).then((result) => { - if(result.data.attachment_histories.length===0){ + if (result.data.attachment_histories.length === 0) { // if(result.data.is_pdf===true){ // this.props.ShowOnlinePdf(result.data.url) // //预览pdf @@ -66,64 +81,66 @@ class Fileslistitem extends Component{ // } // this.props.DownloadFileA(result.data.title,result.data.url) window.open(list.url, '_blank'); - }else{ + } else { this.setState({ - Showoldfiles:true, - allfiles:result.data + Showoldfiles: true, + allfiles: result.data }) } - }).catch((error)=>{ + }).catch((error) => { console.log(error) }) } } - closaoldfilesprops=()=>{ + closaoldfilesprops = () => { this.setState({ - Showoldfiles:false, + Showoldfiles: false, }) } onDelete = (id) => { this.setState({ - Modalstype:true, - Modalstopval:"是否确认删除?", - ModalCancel:this.cancelmodel, - ModalSave:()=>this.savedelete(id), + Modalstype: true, + Modalstopval: "是否确认删除?", + ModalCancel: this.cancelmodel, + ModalSave: () => this.savedelete(id), }) } - cancelmodel=()=>{ + cancelmodel = () => { this.setState({ - Modalstype:false, - Loadtype:false, - Modalstopval:"", - ModalCancel:"", - ModalSave:"", - checkBoxValues:[], + Modalstype: false, + Loadtype: false, + Modalstopval: "", + ModalCancel: "", + ModalSave: "", + checkBoxValues: [], }) } - savedelete=(id)=>{ + savedelete = (id) => { this.setState({ - Modalstype:false, + Modalstype: false, }) const cid = this.props.match.params.coursesId const url = `/files/bulk_delete.json`; - axios.delete(url, { data: { - course_id:cid, + axios.delete(url, { + data: { + course_id: cid, ids: [id], - }}) + } + }) .then((response) => { if (response.data.status == 0) { //Modalstopval:response.data.message, @@ -132,11 +149,11 @@ class Fileslistitem extends Component{ this.setState({ // Modalstype:true, // Modalstopval:"删除成功", - ModalsBottomval:"", + ModalsBottomval: "", // ModalSave:this.cancelmodel, // Loadtype:true, - checkBoxValues:[], - checkAllValue:false + checkBoxValues: [], + checkAllValue: false }) this.props.showNotification("删除成功"); @@ -147,28 +164,30 @@ class Fileslistitem extends Component{ }); } - eventStop = (event) =>{ + eventStop = (event) => { event.stopPropagation() } - render(){ + render() { - const { checkBox, - discussMessage,index + const { + checkBox, + discussMessage, index } = this.props; - return( + let bools = discussMessage.link && discussMessage.link ? false : true; + return (
外链
+ : + "" } - {discussMessage.is_publish===false?+ 资源名称: + + + +
+ { + resourcesnamebool? +请输入资源名称
+ : + "" + } ++ 链接地址: + +
+ { + resourceurlbool? +请输入外链url
+ : + "" + } + + ++ + + {this.props.course_is_public===true?
请填写完整
:""}*/} + +请输入资源描述,最大限制100个字符
:""} + {this.state.Radiovaluetype===true?发布时间不能为空
:""} + + +