diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 324e5bde3..d1357d43f 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -125,8 +125,8 @@ class AccountsController < ApplicationController set_autologin_cookie(user) UserAction.create(:action_id => user.try(:id), :action_type => "Login", :user_id => user.try(:id), :ip => request.remote_ip) - # 注册完成后有一天的试用申请 - UserDayCertification.create(user_id: user.id, status: 1) + # 注册完成后有一天的试用申请(先去掉) + # UserDayCertification.create(user_id: user.id, status: 1) end def set_autologin_cookie(user) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bf8a0651e..af0158cfd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -185,21 +185,29 @@ class ApplicationController < ActionController::Base render :json => { status: status, message: message } end - # 系统全局认证 - def check_auth - day_cer = UserDayCertification.find_by(user_id: current_user.id) - # 如果注册超过24小时则需要完善资料及授权 - if (Time.now.to_i - day_cer.try(:created_at).to_i) > 86400 - if !current_user.profile_completed? - info_url = '/account/profile' - tip_exception(402, info_url) - elsif current_user.certification != 1 - if current_user.apply_actions.exists?(container_type: 'TrialAuthorization', status: 0) - tip_exception(408, "您的试用申请正在审核中,请耐心等待") - end - tip_exception(407, "系统未授权") - end + # 资料是否完善 + def check_account + if !current_user.profile_completed? + info_url = '/account/profile' + tip_exception(402, info_url) end + end + + # 系统全局认证(暂时隐藏试用申请的判断) + def check_auth + # day_cer = UserDayCertification.find_by(user_id: current_user.id) + # # 如果注册超过24小时则需要完善资料及授权 + # if (Time.now.to_i - day_cer.try(:created_at).to_i) > 86400 + # if !current_user.profile_completed? + # info_url = '/account/profile' + # tip_exception(402, info_url) + # elsif current_user.certification != 1 + # if current_user.apply_actions.exists?(container_type: 'TrialAuthorization', status: 0) + # tip_exception(408, "您的试用申请正在审核中,请耐心等待") + # end + # tip_exception(407, "系统未授权") + # end + # end # if current_user.certification != 1 && current_user.apply_actions.exists?(container_type: 'TrialAuthorization', status: 0) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index faad02173..99f942146 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -13,6 +13,7 @@ class CoursesController < ApplicationController before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner] + before_action :check_account, only: [:new, :apply_to_join_course] before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner, :apply_to_join_course, :exit_course] before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt, diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 1187ebafa..b2de6dcad 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -37,7 +37,8 @@ class GamesController < ApplicationController # 上一关、下一关 prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) - next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) + #next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) + next_game = user_next_game(@shixun, game_challenge, @game, @identity) # 关卡点赞数, praise_or_tread = 1则表示赞过 praise_count = game_challenge.praises_count @@ -454,7 +455,7 @@ class GamesController < ApplicationController tip_exception("初始代码为空,代码重置失败") if @content.nil? # 将tpm的代码内容同步更新到tpi - update_file_content(@content, @myshixun.repo_path, path, current_user.mail, current_user.full_name, "reset_original_code") + update_file_content(@content, @myshixun.repo_path, path, current_user.git_mail, current_user.real_name, "reset_original_code") rescue Exception => e uid_logger_error("#{e.message}") tip_exception("初始化代码失败") @@ -471,7 +472,7 @@ class GamesController < ApplicationController # else # content # end - update_file_content(content, @myshixun.repo_path, path, current_user.mail, current_user.full_name, "game passed reset") + update_file_content(content, @myshixun.repo_path, path, current_user.git_mail, current_user.real_name, "game passed reset") else tip_exception("代码重置失败,代码为空") end @@ -962,4 +963,14 @@ class GamesController < ApplicationController @identity = current_user.game_identity(@game) raise Educoder::TipException.new(403, "..") if @identity > User::EDU_GAME_MANAGER end + # identity用户身份 + def user_next_game(shixun, challenge, game, identity) + next_game = game.next_of_current_game(shixun.id, game.myshixun_id, challenge.position) + # 实训允许跳关 、 当前关卡已经通关、 用户是已认证的老师以上权限的人,允许跳关 + if shixun.task_pass || game.status == 2 || identity <= User::EDU_CERTIFICATION_TEACHER + next_game + else + nil + end + end end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f92ed8e2e..2f40f3fc2 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -113,6 +113,15 @@ class HomeworkCommonsController < ApplicationController else if @user_course_identity == Course::STUDENT @work = @homework.user_work(current_user.id) + work = @homework.student_works.find_by(user_id: current_user.id) + + # 学生访问列表时计算个人成绩 + myshixun = Myshixun.find_by(shixun_id: @shixun.id, user_id: current_user.id) + if work && myshixun + challenge_settings = @homework.homework_challenge_settings + games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id)) + HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings + end # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) && diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index cdeca4871..fa47fd7f6 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -7,9 +7,9 @@ class MyshixunsController < ApplicationController ## TPI关卡列表 def challenges # @challenges = Challenge.where(shixun_id: params[:shixun_id]) - - @shixun_status = @myshixun.shixun.status + @shixun = @myshixun.shixun @games = @myshixun.games.includes(:challenge).reorder("challenges.position") + @identity = current_user.game_identity(@games.first) end @@ -42,7 +42,7 @@ class MyshixunsController < ApplicationController if e.message != "ActiveRecord::RecordInvalid" logger.error("######delete_repository_error:#{e.message}") end - raise ActiveRecord::Rollback + raise "delete_repository_error:#{e.message}" end end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 7a2db0666..11016cfbb 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -3,6 +3,8 @@ class ShixunsController < ApplicationController include ApplicationHelper before_action :require_login, :check_auth, except: [:download_file, :index, :menus] + before_action :check_account, only: [:new, :shixun_exec] + before_action :check_auth, except: [:download_file, :index, :menus] before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, @@ -716,7 +718,7 @@ class ShixunsController < ApplicationController logger.error("##########project_fork error #{e.message}") @current_task.destroy! end - raise ActiveRecord::Rollback + raise "实训云平台繁忙(繁忙等级:81)" end end end @@ -769,7 +771,7 @@ class ShixunsController < ApplicationController def update_file content = params[:content] - author_name = current_user.full_name + author_name = current_user.real_name author_email = current_user.git_mail @content = update_file_content content, @repo_path, @path, author_email, author_name, "Edit by browser" end diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 5cbb2a462..586b7352f 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -1,6 +1,7 @@ class SubjectsController < ApplicationController before_action :require_login, :check_auth, except: [:index] # before_action :check_auth, except: [:index] + before_action :check_account, only: [:new] before_action :find_subject, except: [:index, :create, :new, :append_to_stage] before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, diff --git a/app/helpers/myshixuns_helper.rb b/app/helpers/myshixuns_helper.rb index 650f32f40..2a487e361 100644 --- a/app/helpers/myshixuns_helper.rb +++ b/app/helpers/myshixuns_helper.rb @@ -1,2 +1,14 @@ module MyshixunsHelper + + # 获取tpi的identifier, + # identity表示用户关卡的身份 + # task_pass: 实训是否允许跳关 + def get_game_identifier task_pass, game, game_identity + # 允许跳关、 关卡已经开启、 用户是已认证老师以上的身份 + if task_pass || game.status != 3 || game_identity <= User::EDU_CERTIFICATION_TEACHER + game.identifier + else + nil + end + end end diff --git a/app/helpers/shixuns_helper.rb b/app/helpers/shixuns_helper.rb index 71bc833d4..d849053ca 100644 --- a/app/helpers/shixuns_helper.rb +++ b/app/helpers/shixuns_helper.rb @@ -126,12 +126,13 @@ module ShixunsHelper challenge_program_name = [] shixun.challenges.map(&:exec_path).each do |exec_path| challenge_program_name << "\"#{exec_path}\"" - if shixun.main_mirror_name.try(:first) == "Java" + if shixun.main_mirror_name == "Java" if exec_path.nil? || exec_path.split("src/")[1].nil? source = "\"\"" else source = "\"#{exec_path.split("src/")[1].split(".java")[0]}\"" end + logger.info("----source: #{source}") source_class_name << source.gsub("/", ".") if source.present? elsif shixun.main_mirror_name.try(:first) == "C#" if exec_path.nil? || exec_path.split(".")[1].nil? diff --git a/app/models/shixun.rb b/app/models/shixun.rb index e35f9f1a6..82f689e3f 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -4,6 +4,7 @@ class Shixun < ApplicationRecord # status: 0:编辑 1:申请发布 2:正式发布 3:关闭 -1:软删除 # hide_code: 隐藏代码窗口 # code_hidden: 隐藏代码目录 + # task_pass: 跳关 has_many :challenges, dependent: :destroy has_many :challenge_tags, through: :challenges has_many :myshixuns, :dependent => :destroy diff --git a/app/views/courses/search_users.json.jbuilder b/app/views/courses/search_users.json.jbuilder index d735de970..ac826fdf2 100644 --- a/app/views/courses/search_users.json.jbuilder +++ b/app/views/courses/search_users.json.jbuilder @@ -2,8 +2,8 @@ json.users do json.array! @users do |user| json.id user.id json.name user.real_name - json.student_id user.user_extension.try(:student_id) - json.school_name user.user_extension.school.name + json.student_id user&.student_id + json.school_name user&.school_name json.added @course.course_member?(user.id, 4) end end diff --git a/app/views/myshixuns/challenges.json.jbuilder b/app/views/myshixuns/challenges.json.jbuilder index 802c2b561..0be94d9fd 100644 --- a/app/views/myshixuns/challenges.json.jbuilder +++ b/app/views/myshixuns/challenges.json.jbuilder @@ -3,7 +3,7 @@ json.array! @games do |game| json.partial! 'challenges/challenge', locals: { challenge: challenge } json.status game.status json.star game.star - json.identifier game.identifier - json.get_gold game.user_get_gold_and_experience(@shixun_status, challenge)[0] - json.get_experience game.user_get_gold_and_experience(@shixun_status, challenge)[1] + json.identifier get_game_identifier(@shixun.task_pass, game, @identity) + json.get_gold game.user_get_gold_and_experience(@shixun.status, challenge)[0] + json.get_experience game.user_get_gold_and_experience(@shixun.status, challenge)[1] end \ No newline at end of file diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index 164c943d0..d9eb736ad 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -7,6 +7,7 @@ json.is_teacher @user.user_extension&.teacher? json.user_identity @user.identity json.tidding_count 0 json.user_phone_binded @user.phone.present? +json.profile_completed @user.profile_completed? if @course json.course_identity @course_identity json.course_name @course.name diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index ad7172be5..849621259 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -502,7 +502,7 @@ class Coursesleftnav extends Component{ NavmodalValues:"名称不能为空" }) return - }else if(NavmodalValue.length>20){ + }else if(NavmodalValue.length>60){ this.setState({ NavmodalValuetype:true, NavmodalValues:"名称不能超过60个字" diff --git a/public/react/src/modules/courses/css/Courses.css b/public/react/src/modules/courses/css/Courses.css index c69b147fa..e214bd81d 100644 --- a/public/react/src/modules/courses/css/Courses.css +++ b/public/react/src/modules/courses/css/Courses.css @@ -990,8 +990,15 @@ samp { .newcourses .ant-input{ width:280px; margin-left: 11px; - height: 40px; + height: 40px !important; } + +.newcourses .ant-input{ + width:280px; + margin-left: 11px; + height: 40px !important; +} + .newcourses .ant-select-selection--single{ width: 280px; /*margin-left: 11px;*/ diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index 73c1dded9..5f63952cb 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -1,5 +1,5 @@ import React, {Component} from "React"; -import {Form, Select, Input, Button, Checkbox, DatePicker,Spin,Icon} from "antd"; +import {Form, Select, Input, Button, Checkbox, DatePicker,Spin,Icon,AutoComplete} from "antd"; import ApplyForAddOrgModal from '../../user/modal/ApplyForAddOrgModal'; import axios from 'axios'; import "../css/Courses.css"; @@ -47,8 +47,8 @@ class CoursesNew extends Component { let coursesId = this.props.match.params.coursesId; let user_school=this.props.current_user&&this.props.current_user.user_school; - this.getschool("") - this.Searchvalue("") + // this.getschool("") + // this.Searchvalue("") if (coursesId != undefined) { let url = "/courses/" + coursesId + "/settings.json" axios.get(url).then((result) => { @@ -285,8 +285,8 @@ class CoursesNew extends Component { this.setState({ searchlist: result.data.course_lists, - // course:value, - fetching: false + // course:value, + }) } // this.props.form.setFieldsValue({ @@ -298,10 +298,11 @@ class CoursesNew extends Component { } handleSearch=(value)=>{ + if(value!=""){ this.props.form.setFieldsValue({ classroom:value, - // course:value + // course:value }); this.Searchvalue(value) } @@ -311,7 +312,7 @@ class CoursesNew extends Component { handleChange=(value)=>{ this.props.form.setFieldsValue({ - // course:value, + // course:value, classroom:value }) }; @@ -319,21 +320,27 @@ class CoursesNew extends Component { handleSearchschool=(value)=>{ if(value!="") { - this.props.form.setFieldsValue({ - // school: value, + // this.props.form.setFieldsValue({ + // // school: value, + // fetching: true, + // }); + this.setState({ fetching: true, - }); - + school: value + }) this.getschool(value) } }; handleChangeschools=(value)=>{ - this.props.form.setFieldsValue({ - // school: value, - fetching: true, - }); + // this.props.form.setFieldsValue({ + // // school: value, + // fetching: true, + // }); + // this.setState({ + // fetching: true + // }) } handleChangeschool=(value)=>{ @@ -359,9 +366,13 @@ class CoursesNew extends Component { if (result.data.status===0) { this.setState({ searchlistscholl: result.data.school_names, - // school: value - }) + }) + if(result.data.school_names.length!=0){ + this.setState({ + fetching: false + }) + } } }).catch((error)=>{ console.log(error) @@ -420,8 +431,7 @@ class CoursesNew extends Component { `} -