diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index ebce98b62..9e87d3799 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -151,7 +151,7 @@ class ChallengesController < ApplicationController def index uid_logger("identifier: #{params}") - @challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id) + @challenges = @shixun.challenges.fields_for_list @editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员 @user = current_user diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 75d515186..223871968 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -598,7 +598,7 @@ class CoursesController < ApplicationController normal_status(0, "操作成功") rescue => e uid_logger_error(e.message) - tip_exception("操作失败") + tip_exception(e.message) raise ActiveRecord::Rollback end end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 7f2519b99..c8cf36824 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1459,7 +1459,8 @@ class HomeworkCommonsController < ApplicationController if game_codes.count > 0 code_rate += game_codes.map(&:rate).sum / challenge.path.split(";").length end - target = game_codes.count > 0 ? game_codes[0].target_user_id : nil + logger.info("#####game_codes: #{game_codes}") + #target = game_codes.count > 0 ? game_codes[0].target_user_id : nil # 作品完成时间 game = challenge.games.find_by(user_id: @user.id) end_time = game.end_time @@ -1467,7 +1468,7 @@ class HomeworkCommonsController < ApplicationController all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f final_score = @student_work.work_challenge_score game, all_score # 抄袭用户 - copy_user = User.find_by_id(game_codes[0].target_user_id) + copy_user = User.find_by_id(game_codes[0].try(:target_user_id)) copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present? # 代码部分 code_list = [] @@ -1477,7 +1478,7 @@ class HomeworkCommonsController < ApplicationController code_list << {path: path, origin_content: info.origin_content, target_content: info.target_content} end end - + # TODO: 这里本来应该前端做的,但是现在页面已经刷不开了。 {code_rate: code_rate, copy_user_id: copy_user.try(:id), end_time: end_time, final_score: final_score, all_score: all_score, copy_end_time: copy_end_time, copy_username: copy_user.try(:full_name), username: game.user.full_name, code_list: code_list, subject: challenge.subject, position: challenge.position, diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 03acd76cc..e4dffec23 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -40,6 +40,8 @@ class Users::VideosController < Users::BaseController def batch_publish Videos::BatchPublishService.call(observed_user, batch_publish_params) render_ok + rescue Videos::BatchPublishService::Error => ex + render_error(ex.message) end private diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 8e4d2ae42..adb54fae9 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -1,7 +1,6 @@ class Challenge < ApplicationRecord # difficulty: 关卡难度: 1.简单 2.中等 3.困难 # show_type: 效果展示:-1.无效果 1.图片 2.apk/exe 3.txt 4.html 5.mp3 6.mp4 - default_scope { order("challenges.position asc") } belongs_to :shixun, :touch => true, counter_cache: true belongs_to :user diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 33e40ee52..d57edf497 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -8,7 +8,7 @@ class CourseGroup < ApplicationRecord has_many :homework_group_reviews, :dependent => :destroy scope :by_group_ids, lambda { |ids| where(id: ids)} - validates :name, length: { maximum: 20 } + validates :name, length: { maximum: 60 } after_create :generate_invite_code diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 1839edf93..81b444c0a 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -5,7 +5,7 @@ class Shixun < ApplicationRecord # hide_code: 隐藏代码窗口 # code_hidden: 隐藏代码目录 # task_pass: 跳关 - has_many :challenges, dependent: :destroy + has_many :challenges, -> {order("challenges.position asc")}, dependent: :destroy has_many :challenge_tags, through: :challenges has_many :myshixuns, :dependent => :destroy has_many :shixun_members, dependent: :destroy diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 3ff16dc57..e435b9508 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -1,4 +1,6 @@ class Videos::BatchPublishService < ApplicationService + Error = Class.new(StandardError) + attr_reader :user, :params def initialize(user, params) @@ -16,6 +18,8 @@ class Videos::BatchPublishService < ApplicationService video = user.videos.find_by(uuid: param[:video_id]) next if video.blank? || video.processing_video_apply.present? + raise Error, '视频还未上传完成' if video.vod_uploading? + video.title = param[:title].to_s.strip.presence || video.title video.apply_publish video.save! diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 51c30ad92..bbdf45440 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -17,7 +17,8 @@ if question.question_type <= 2 #当为选择题或判断题时,只显示选 end json.question_choices do json.array! exercise_choices.each_with_index.to_a do |a,index| - standard_answer_b = standard_answers_array.include?(a.choice_position) + #TODO: 旧版本来一个题只有一个标准答案的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + standard_answer_b = standard_answers_array.join("").include?(a.choice_position.to_s) user_answer_b = user_answer.include?(a.id) json.c_position (index+1) if ex_choice_random_boolean #当选项随机时,选项位置以此为准,否则不出现 json.choice_id a.id diff --git a/public/react/src/App.js b/public/react/src/App.js index e71ce4a9a..8004e05f8 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -274,6 +274,11 @@ class App extends Component { // }, (error) => { // //TODO 这里如果样式变了会出现css不加载的情况 // }); + + window.addEventListener('error', (event) => { + const msg = `${event.type}: ${event.message}`; + console.log(msg) + }); } //修改登录方法 Modifyloginvalue=()=>{ diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js index f224526e6..1a910f224 100644 --- a/public/react/src/common/UrlTool.js +++ b/public/react/src/common/UrlTool.js @@ -13,7 +13,7 @@ export function getImageUrl(path) { export function setImagesUrl(path){ const local = 'http://47.96.87.25:48080' let firstStr=path.substr(0,1); - console.log(firstStr); + // console.log(firstStr); if(firstStr=="/"){ return isDev?`${local}${path}`:`${path}`; }else{ diff --git a/public/react/src/modules/courses/ListPageIndex.js b/public/react/src/modules/courses/ListPageIndex.js index 8c87c8731..9c1923452 100644 --- a/public/react/src/modules/courses/ListPageIndex.js +++ b/public/react/src/modules/courses/ListPageIndex.js @@ -68,17 +68,21 @@ class ListPageIndex extends Component{ constructor(props) { super(props); this.state={ - yslGuideone:null, + yslGuideone:undefined, + mysearch:undefined, } } componentDidMount(){ - var yslGuideone = window.localStorage.getItem('yslGuideone'); + var yslGuideone = window.sessionStorage.getItem('yslGuideone'); console.log("77"); console.log(yslGuideone); + var mysearchs= this.props.location.search===""?undefined:this.props.location.search===undefined?undefined:this.props.location.search==="?exhibition=true"?true:undefined; this.setState({ yslGuideone:yslGuideone, + mysearch:mysearchs, }) + } // // getleftNavid=(navid,newselectnavid)=>{ @@ -88,34 +92,44 @@ class ListPageIndex extends Component{ // navttype:newselectnavid // }) // } - setwindowlocal=(bool)=>{ - window.localStorage.setItem('yslGuideone', bool); + componentWillUnmount(){ + window.sessionStorage.setItem('yslGuideone', false); + } + setwindowlocal=(bool)=>{ + window.sessionStorage.setItem('yslGuideone', bool); this.setState({ yslGuideone:bool, - }) + mysearch:undefined, + }); + var currenturl = this.props.location.pathname; + var newUrl = (currenturl.split("?"))[0]; + window.history.pushState('','',newUrl); } render() { - let {yslGuideone} =this.state; + let {yslGuideone,mysearch} =this.state; // console.log("98"); // console.log(yslGuideone); + // console.log(this.props.isAdmin()); + // // var yslGuideones = window.sessionStorage.getItem('yslGuideone'); + // console.log(this.props); + // console.log(this.props.location.search); return (
- - {item.username} - 的代码文件 - - - {item.copy_username} - 的代码文件 - -
- -+ + {item.username} + 的代码文件 + + + {item.copy_username} + 的代码文件 + +
+ +