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..a1f37687d 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, :create, :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,
@@ -116,6 +117,7 @@ class CoursesController < ApplicationController
# GET /courses/new
def new
@course = Course.new
+ normal_status("成功")
end
# Get /courses/:id/settings
@@ -926,12 +928,12 @@ class CoursesController < ApplicationController
role = course_message.content == 2 ? '7' : '9' # 7:助教 9:教师
ApplyTeacherRoleJoinCourseNotifyJob.perform_later(current_user.id, course.id, role)
- teacher_role = 1
message = "#{course_message.content == 2 ? '助教' : '教师'}申请已提交,请等待审核"
else
message = "#{existing_course_message.content == 2 ? '助教' : '教师'}申请已提交,请等待审核"
end
end
+ teacher_role = 1
end
if teacher_role && current_user.student_of_course?(course)
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index a51dccb6f..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
@@ -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..29f270a34 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)
+ # 学生访问列表时计算个人成绩
+ if @homework.homework_type == "practice"
+ 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
+ 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 99cee4185..1c272e02d 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, :create, :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
diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb
index 5cbb2a462..bc5b0a607 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, :create]
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/models/homework_common.rb b/app/models/homework_common.rb
index ac64b92c1..9aa4a8fe1 100644
--- a/app/models/homework_common.rb
+++ b/app/models/homework_common.rb
@@ -35,7 +35,7 @@ class HomeworkCommon < ApplicationRecord
has_many :homework_review_results, :dependent => :destroy
validates :name, length: { maximum: 60 }
- validates :description, length: { maximum: 5000 }
+ validates :description, length: { maximum: 15000 }
validates :reference_answer, length: { maximum: 5000 }
# after_update :update_activity
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/db/migrate/20190726082937_add_is_md_for_homeworks.rb b/db/migrate/20190726082937_add_is_md_for_homeworks.rb
new file mode 100644
index 000000000..0b25dde97
--- /dev/null
+++ b/db/migrate/20190726082937_add_is_md_for_homeworks.rb
@@ -0,0 +1,12 @@
+class AddIsMdForHomeworks < ActiveRecord::Migration[5.2]
+ def change
+ # add_column :homework_commons, :is_md, :boolean, :default => true
+ # add_column :homework_banks, :is_md, :boolean, :default => true
+ #
+ #
+ # add_column :exercise_questions,:is_md, :boolean, :default => true
+ # add_column :poll_questions,:is_md, :boolean, :default => true
+ #
+ # add_column :exercise_bank_questions, :is_md, :boolean, :default => true
+ end
+end
diff --git a/db/migrate/20190726083814_migrate_course_is_md.rb b/db/migrate/20190726083814_migrate_course_is_md.rb
new file mode 100644
index 000000000..6988db14a
--- /dev/null
+++ b/db/migrate/20190726083814_migrate_course_is_md.rb
@@ -0,0 +1,14 @@
+class MigrateCourseIsMd < ActiveRecord::Migration[5.2]
+ def change
+ # HomeworkCommon.where(homework_type: [1, 3]).where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
+ # HomeworkBank.where(homework_type: [1, 3]).where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
+ #
+ # HomeworkCommon.where(homework_type: [1, 3]).where("created_at >= '2019-07-21 00:00:00' and homework_bank_id is not null").each do |homework|
+ #
+ # end
+ #
+ # ExerciseQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
+ # PollQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
+ # ExerciseBankQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
+ end
+end
diff --git a/public/react/src/App.js b/public/react/src/App.js
index 191b0f0c8..49dac07cd 100644
--- a/public/react/src/App.js
+++ b/public/react/src/App.js
@@ -18,6 +18,9 @@ import Notcompletedysl from './modules/user/Notcompletedysl';
import Trialapplicationysl from './modules/login/Trialapplicationysl';
import Trialapplicationreview from './modules/user/Trialapplicationreview';
import Addcourses from "./modules/courses/coursesPublic/Addcourses";
+import AccountProfile from"./modules/user/AccountProfile";
+
+
import Trialapplication from './modules/login/Trialapplication'
import NotFoundPage from './NotFoundPage'
@@ -278,6 +281,7 @@ class App extends Component {
{ + if (this.props.delay == true) { + (function(content, selector) { + // console.log('selector: ', selector) + setTimeout(() => { + markdownToHTML(content, selector) + }, 600) + })(content, selector) + } else { + markdownToHTML(content, selector) + } + } componentDidUpdate = (prevProps) => { if (this.props.content) { if ( prevProps.content != this.props.content ) { - markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`) + this._markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`) } } } componentDidMount () { - this.props.content && markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`) + this.props.content && this._markdownToHTML(this.props.content, `.markdown_to_html_${this.props.selector || ''}`) } render(){ - + const { style, className } = this.props return( -
该文件将直接显示给学生,需要学生在其中填写代码
该文件由平台执行,用来测试平台学员代码是否正确
该路径下的文件将在学员评测本关任务时,作为原始图片显示在查看效果页,供学员参考,任务为图片处理时请指定该路径,并注意与程序文件所在文件夹分开 @@ -980,8 +1006,8 @@ export default class TPMevaluation extends Component { id="shixun_file_standard_picture_path" name="challenge[expect_picture_path]" placeholder="请选择版本库中存储了标准答案代码输出文件的路径。例:src/step1/expectedimages" value={shixunfilestandardpicturepath} - onInput={(e)=>this.updatepath(e,"shixunfilestandardpicturepath")} - onClick={(e)=>this.getfilepath(e,"shixunfilestandardpicturepath")} + onInput={(e)=>this.updatepath(e,"shixunfilestandardpicturepath",2)} + onClick={(e)=>this.getfilepath(e,"shixunfilestandardpicturepath",2)} />
该路径下的文件将在学员评测本关任务时,作为参考答案显示在查看效果页,供学员参考任务输出结果为文件时请指定该路径,并注意与程序文件所在文件夹分开 @@ -1001,8 +1027,8 @@ export default class TPMevaluation extends Component { this.updatepath(e,"shixunfilepicturepath")} - onClick={(e)=>this.getfilepath(e,"shixunfilepicturepath")} + onInput={(e)=>this.updatepath(e,"shixunfilepicturepath",2)} + onClick={(e)=>this.getfilepath(e,"shixunfilepicturepath",2)} placeholder="请在版本库中指定用来保存学员代码实际输出结果的路径。例:src/step1/outputimages"/>
学员评测本关任务时生成的文件将保存在该路径下,并作为实际输出显示在查看效果页,供学员确认任务输出结果为文件时请指定该路径,并注意与程序文件所在文件夹分开 diff --git a/public/react/src/modules/tpm/newshixuns/Newshixuns.js b/public/react/src/modules/tpm/newshixuns/Newshixuns.js index 346be3351..f9c8f5b10 100644 --- a/public/react/src/modules/tpm/newshixuns/Newshixuns.js +++ b/public/react/src/modules/tpm/newshixuns/Newshixuns.js @@ -743,10 +743,12 @@ class Newshixuns extends Component { onChangeTimePicker = (value, dateString) => { this.setState({ - TimePickervalue: handleDateStrings(dateString) + TimePickervalue: moment(handleDateStrings(dateString)) }) } - // 附件相关 START + + + // 附件相关 START handleChange = (info) => { console.log("handleChange1"); let fileList = info.fileList; @@ -1279,13 +1281,14 @@ class Newshixuns extends Component {
您需要去完善您的个人资料,才能使用此功能
+您尚未完善个人资料
请在完成资料后,提交试用申请
完善您的资料,将获得更多的使用权限