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

dev_unstable
hjm 6 years ago
commit 7af46f772e

@ -162,28 +162,30 @@ class AttachmentsController < ApplicationController
def attachment_candown def attachment_candown
unless current_user.admin? || current_user.business? unless current_user.admin? || current_user.business?
candown = true candown = true
if @file.container && current_user.logged? unless params[:type] == 'history'
# 课堂资源、作业、毕设相关资源的权限判断 if @file.container && current_user.logged?
if @file.container.is_a?(Course) # 课堂资源、作业、毕设相关资源的权限判断
course = @file.container if @file.container.is_a?(Course)
candown = current_user.member_of_course?(course) || @file.is_public == 1 course = @file.container
elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic) candown = current_user.member_of_course?(course) || @file.is_public == 1
course = @file.container&.course elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic)
candown = current_user.member_of_course?(course) course = @file.container&.course
elsif @file.container.is_a?(StudentWork) candown = current_user.member_of_course?(course)
course = @file.container&.homework_common&.course elsif @file.container.is_a?(StudentWork)
candown = current_user.member_of_course?(course) course = @file.container&.homework_common&.course
elsif @file.container.is_a?(StudentWorksScore) candown = current_user.member_of_course?(course)
course = @file.container&.student_work&.homework_common&.course elsif @file.container.is_a?(StudentWorksScore)
candown = current_user.member_of_course?(course) course = @file.container&.student_work&.homework_common&.course
elsif @file.container.is_a?(GraduationWork) candown = current_user.member_of_course?(course)
course = @file.container&.graduation_task&.course elsif @file.container.is_a?(GraduationWork)
candown = current_user.member_of_course?(course) course = @file.container&.graduation_task&.course
elsif @file.container.is_a?(GraduationWorkScore) candown = current_user.member_of_course?(course)
course = @file.container&.graduation_work&.graduation_task&.course elsif @file.container.is_a?(GraduationWorkScore)
candown = current_user.member_of_course?(course) course = @file.container&.graduation_work&.graduation_task&.course
candown = current_user.member_of_course?(course)
end
tip_exception(403, "您没有权限进入") if course.present? && !candown
end end
tip_exception(403, "您没有权限进入") if course.present? && !candown
end end
end end
end end

@ -1129,7 +1129,7 @@ class CoursesController < ApplicationController
def validate_course_name def validate_course_name
tip_exception("课堂名称不能为空!") if params[:course][:name].blank? tip_exception("课堂名称不能为空!") if params[:course][:name].blank?
if params[:subject_id].blank? || (@course && @course.subject.blank?) if params[:subject_id].blank? && @course.blank? || (@course && @course.subject.blank?)
tip_exception("课程名称不能为空!") if params[:course_list_name].blank? tip_exception("课程名称不能为空!") if params[:course_list_name].blank?
tip_exception("课堂名称应以课程名称开头命名") unless params[:course][:name].index(params[:course_list_name]) && tip_exception("课堂名称应以课程名称开头命名") unless params[:course][:name].index(params[:course_list_name]) &&
params[:course][:name].index(params[:course_list_name]) == 0 params[:course][:name].index(params[:course_list_name]) == 0

@ -1566,15 +1566,22 @@ class ExercisesController < ApplicationController
def check_user_id_start_answer #判断用户在开始答题时是否有用户id传入,如果为老师则id必需否则为当前用户的id def check_user_id_start_answer #判断用户在开始答题时是否有用户id传入,如果为老师则id必需否则为当前用户的id
user_login = params[:login] user_login = params[:login]
# exercise_current_user_id = params[:user_id]
if user_login.blank? && @user_course_identity < Course::STUDENT #id不存在且当前为老师/管理员等 if user_login.blank? && @user_course_identity < Course::STUDENT #id不存在且当前为老师/管理员等
normal_status(-1,"请输入学生登陆名!") normal_status(-1,"请输入学生登陆名!")
else else
@ex_answerer = User.find_by(login: user_login) #回答者 if @user_course_identity < Course::STUDENT || @exercise.score_open
@ex_answerer = user_login.blank? ? current_user : User.find_by(login: user_login)
else
@ex_answerer = current_user
end
if @ex_answerer.blank? if @ex_answerer.blank?
normal_status(404,"答题用户不存在") normal_status(404,"答题用户不存在")
elsif @user_course_identity > Course::STUDENT && !@exercise.is_public
normal_status(403,"非公开试卷")
else else
@exercise_current_user_id = @ex_answerer.id || current_user.id # @exercise_current_user_id = @ex_answerer.id || current_user.id
@exercise_current_user_id = @ex_answerer.id
end end
end end
end end

@ -258,7 +258,7 @@ module ApplicationHelper
end end
def download_url attachment def download_url attachment
attachment_path(attachment).gsub("/api","") attachment_path(attachment)
end end
# 耗时:天、小时、分、秒 # 耗时:天、小时、分、秒

@ -36,7 +36,7 @@ class HomeworkCommon < ApplicationRecord
validates :name, length: { maximum: 60 } validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 15000 } validates :description, length: { maximum: 15000 }
validates :reference_answer, length: { maximum: 5000 } validates :reference_answer, length: { maximum: 15000 }
# after_update :update_activity # after_update :update_activity
before_destroy :update_homework_bank_quotes before_destroy :update_homework_bank_quotes

@ -8,3 +8,4 @@ json.downloads_count attachment.downloads_count
json.created_on attachment.created_on json.created_on attachment.created_on
json.url attachment_path(attachment, type: 'history').gsub("/api","") json.url attachment_path(attachment, type: 'history').gsub("/api","")
json.is_pdf attachment.is_history_pdf? json.is_pdf attachment.is_history_pdf?
json.attachment_id attachment.attachment_id

@ -5,6 +5,7 @@ json.course_id @course.id
json.school @course.school&.name json.school @course.school&.name
json.class_period @course.class_period json.class_period @course.class_period
json.credit @course.credit json.credit @course.credit
json.start_date @course.start_date
json.end_date @course.end_date json.end_date @course.end_date
json.is_public @course.is_public json.is_public @course.is_public
json.course_module_types @course.course_modules.where(hidden: 0).pluck(:module_type) json.course_module_types @course.course_modules.where(hidden: 0).pluck(:module_type)

@ -1,3 +1,9 @@
json.partial! 'attachments/attachment_small', attachment: @file # json.partial! 'attachments/attachment_small', attachment: @file
json.id @file.id
json.title @file.title
json.filesize number_to_human_size(@file.filesize)
json.url download_url(@file).gsub("/api","")
json.created_on @file.created_on
json.is_pdf @file.is_pdf?
json.partial! "attachment_histories/list", attachment_histories: @attachment_histories json.partial! "attachment_histories/list", attachment_histories: @attachment_histories

@ -38,6 +38,8 @@ namespace :excellent_course_exercise do
rand_num = index < pass_count - 1 ? 20 : rand(1..16) rand_num = index < pass_count - 1 ? 20 : rand(1..16)
elsif exercise_question_ids.length == 17 elsif exercise_question_ids.length == 17
rand_num = index < pass_count - 1 ? rand(13..17) : rand(1..11) rand_num = index < pass_count - 1 ? rand(13..17) : rand(1..11)
elsif exercise_question_ids.length == 39
rand_num = index < pass_count - 1 ? rand(30..39) : rand(1..18)
else else
rand_num = exercise_question_ids.length rand_num = exercise_question_ids.length
end end

@ -722,15 +722,19 @@ class Coursesleftnav extends Component{
let {url}=this.state; let {url}=this.state;
if (key === this.props.indexs) { if (key === this.props.indexs) {
this.props.unlocationNavfun(undefined) this.props.unlocationNavfun(undefined)
this.props.history.replace(urls);
} else { } else {
this.props.unlocationNavfun(key) this.props.unlocationNavfun(key)
this.props.history.replace(urls);
} }
if(urls!=url){ if(urls!=url){
this.props.history.replace(urls); this.props.history.replace(urls);
} }
if(this.props.indexs===undefined){ // if(this.props.indexs===undefined){
this.props.history.replace(urls); //
} // }else{
//
// }
} }
maincontent=(item,key)=>{ maincontent=(item,key)=>{

@ -29,7 +29,7 @@ class InfosBanner extends Component{
<div className="bannerPanel mb60"> <div className="bannerPanel mb60">
<div className="educontent"> <div className="educontent">
<div className="clearfix color-white mb25"> <div className="clearfix color-white mb25">
<p className="myPhoto mr30 fl"><img alt="头像" src={data && `${getImageUrl('images/'+data.avatar_url)}`}/></p> <p className="myPhoto mr20 fl"><img alt="头像" src={data && `${getImageUrl('images/'+data.avatar_url)}`}/></p>
<div className="fl"> <div className="fl">
<p className="clearfix mt20"> <p className="clearfix mt20">
<span className="username task-hide" style={{"maxWidth":'370px'}}>{data && data.name}</span> <span className="username task-hide" style={{"maxWidth":'370px'}}>{data && data.name}</span>
@ -38,9 +38,9 @@ class InfosBanner extends Component{
<span className="userpost"><label>{data && data.identity}</label></span> <span className="userpost"><label>{data && data.identity}</label></span>
} }
</p> </p>
<p className="mt20"> <p className="mt15">
<Tooltip placement='bottom' title={ data && data.professional_certification ?"已职业认证":"未职业认证"}> <Tooltip placement='bottom' title={ data && data.professional_certification ?"已职业认证":"未职业认证"}>
<i className={ data && data.professional_certification ? "iconfont icon-shenfenzhenghaomaguizheng font-18 user-colorgrey-green mr30 ml2":"iconfont icon-shenfenzhenghaomaguizheng font-18 user-colorgrey-B8 mr30 ml2"}></i> <i className={ data && data.professional_certification ? "iconfont icon-shenfenzhenghaomaguizheng font-18 user-colorgrey-green mr20 ml2":"iconfont icon-shenfenzhenghaomaguizheng font-18 user-colorgrey-B8 mr20 ml2"}></i>
</Tooltip> </Tooltip>
<Tooltip placement='bottom' title={ data && data.authentication ?"已实名认证":"未实名认证"}> <Tooltip placement='bottom' title={ data && data.authentication ?"已实名认证":"未实名认证"}>
<i className={ data && data.authentication ? "iconfont icon-renzhengshangjia font-18 user-colorgrey-green":"iconfont icon-renzhengshangjia font-18 user-colorgrey-B8"}></i> <i className={ data && data.authentication ? "iconfont icon-renzhengshangjia font-18 user-colorgrey-green":"iconfont icon-renzhengshangjia font-18 user-colorgrey-B8"}></i>
@ -68,7 +68,7 @@ class InfosBanner extends Component{
</span> </span>
: :
<span className="fl mt35 ml60"> <span className="fl mt35 ml60">
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/messages/${login}/message_detail?target_ids=${id}`} className="user_default_btn user_yellow_btn fl font-18">私信</a> <a href={`/messages/${login}/message_detail?target_ids=${id}`} className="user_default_btn user_yellow_btn fl font-18">私信</a>
</span> </span>
} }
</div> </div>

@ -126,7 +126,7 @@ class InfosCourse extends Component{
</p> </p>
<div className="square-list clearfix"> <div className="square-list clearfix">
{ {
page == 1 && is_current && page == 1 && is_current && !category &&
this.props.current_user && this.props.current_user.user_identity != "学生" ? <Create href={"/courses/new"} name={"新建课堂"} index="1"></Create> : "" this.props.current_user && this.props.current_user.user_identity != "学生" ? <Create href={"/courses/new"} name={"新建课堂"} index="1"></Create> : ""
} }
{ {

@ -148,7 +148,7 @@ class InfosPath extends Component{
</div> </div>
<div className="square-list clearfix"> <div className="square-list clearfix">
{ {
page == 1 && is_current && page == 1 && is_current && !category &&
this.props.current_user && this.props.current_user.user_identity != "学生" ? <Create href={"/paths/new"} name={"新建实践课程"} index="3"></Create>:"" this.props.current_user && this.props.current_user.user_identity != "学生" ? <Create href={"/paths/new"} name={"新建实践课程"} index="3"></Create>:""
} }
{ {

@ -121,7 +121,7 @@ class InfosProject extends Component{
</p> </p>
<div className="square-list clearfix"> <div className="square-list clearfix">
{ {
page == 1 && is_current && this.props.current_user && this.props.current_user.user_identity != "学生" ? page == 1 && is_current && this.props.current_user && !category && this.props.current_user.user_identity != "学生" ?
<Create href={`${this.props.Headertop && this.props.Headertop.old_url}/projects/new`} name={"新建项目"} index="4"></Create>:"" <Create href={`${this.props.Headertop && this.props.Headertop.old_url}/projects/new`} name={"新建项目"} index="4"></Create>:""
} }
{ {

@ -157,7 +157,7 @@ class InfosShixun extends Component{
</div> </div>
<div className="square-list clearfix"> <div className="square-list clearfix">
{ {
page == 1 && is_current && this.props.current_user && this.props.current_user.user_identity != "学生" ? page == 1 && is_current && !category && this.props.current_user && this.props.current_user.user_identity != "学生" ?
<Create href={"/shixuns/new"} name={"新建实训"} index="2"></Create>:"" <Create href={"/shixuns/new"} name={"新建实训"} index="2"></Create>:""
} }
{ {

Loading…
Cancel
Save