Merge branch 'dev_aliyun' into dev_course

dev_course
cxt 6 years ago
commit 15b863a618

1
.gitignore vendored

@ -47,6 +47,7 @@
public/upload.html
/config/configuration.yml
/config/environments/production.rb
/config/initializers/gitlab_config.rb
/db/schema.rb
.vscode/

@ -45,12 +45,12 @@ gem 'rqrcode_png'
gem 'acts-as-taggable-on', '~> 6.0'
group :development, :test do
group :'development.rb.example', :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails', '~> 3.8'
end
group :development do
group :'development.rb.example' do
gem 'awesome_print'
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'

@ -183,19 +183,20 @@ class ApplicationController < ActionController::Base
# 系统全局认证
#
def check_auth
old_edu_host = edu_setting('old_edu_host')
ue = current_user.user_extension
if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank?
info_url = old_edu_host + '/account/user_info'
render :json => { status: 402, url: info_url }
elsif current_user.certification != 1
day_cer = UserDayCertification.where(user_id: current_user.id).last
unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
account_url = old_edu_host + "/my/account"
render :json => { status: 402, url: account_url }
end
end
# old_edu_host = edu_setting('old_edu_host')
# ue = current_user.user_extension
#
# if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank?
# info_url = old_edu_host + '/account/user_info'
# render :json => { status: 402, url: info_url }
# elsif current_user.certification != 1
# day_cer = UserDayCertification.where(user_id: current_user.id).last
# unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
# account_url = old_edu_host + "/my/account"
# render :json => { status: 402, url: account_url }
# end
# end
true
end
# 身份资料的认证:

@ -913,7 +913,7 @@ class CoursesController < ApplicationController
def left_banner
@user = current_user
@is_teacher = @user.teacher_of_course?(@course)
@course_modules = @course.course_modules.where.not(module_type: "activity").where(hidden: 0)
@course_modules = @course.course_modules.where(hidden: 0)
@hidden_modules = @course.course_modules.where(hidden: 1)
@second_category_type = ["shixun_homework", "graduation", "attachment", "board", "course_group"]
end

@ -62,6 +62,22 @@ class GamesController < ApplicationController
praise_count: praise_count, user_praise: user_praise, time_limit: time_limit,
tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher,
myshixun_manager: myshixun_manager}
if @shixun.vnc
begin
shixun_tomcat = edu_setting('shixun_tomcat')
service_host = edu_setting('vnc_url')
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(@shixun.mirror_repositories))}"}
res = uri_post uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")
end
@url = "http://#{service_host}:#{res['port']}}/vnc_lite.html?password=headless"
Rails.logger.info("66666666sssssss#{url}")
rescue Exception => e
Rails.logger.error(e.message)
end
end
# 区分选择题和编程题st0编程题
if @st == 0

@ -109,8 +109,8 @@ class GraduationTasksController < ApplicationController
end
# 排序
rorder = params[:order] || "updated_at"
b_order = params[:b_order] || "desc"
rorder = params[:order].blank? ? "updated_at" : params[:order]
b_order = params[:b_order].blank? ? "desc" : params[:b_order]
if rorder == "created_at" || rorder == "work_score"
@work_list = @work_list.order("graduation_works.#{rorder} #{b_order}")
elsif rorder == "student_id"

@ -1,7 +1,7 @@
class MyshixunsController < ApplicationController
before_action :require_login, :except => [:training_task_status, :code_runinng_message]
before_action :find_myshixun, :except => [:training_task_status]
before_action :find_repo_name, :except => [:training_task_status]
before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message]
before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message]
skip_before_action :verify_authenticity_token, :only => [:html_content]
## TPI关卡列表

@ -1,5 +1,5 @@
class ShixunsController < ApplicationController
# before_action :require_login, except: [:download_file, :index, :menus]
before_action :require_login, except: [:download_file, :index, :menus]
before_action :check_auth, except: [:download_file, :index]
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics,
@ -492,6 +492,7 @@ class ShixunsController < ApplicationController
if current_myshixun
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置
uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}")
if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort
# 这里页面弹框要收到 当前用户myshixun的identifier.
tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game")

@ -582,6 +582,9 @@ class StudentWorksController < ApplicationController
score_appeal.tidings.update_all(status: 1)
if params[:status].to_i == 3
# 申诉成功后该评分失效
score.update_attributes(is_invalid: 1)
# 申诉成功后 扣匿评学生的违规匿评扣分
sw = @homework.student_works.find_by(user_id: score.user_id)
sw.update_attribute("appeal_penalty", @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present?

@ -41,7 +41,7 @@ module StudentWorksHelper
def student_efficiency(homework_common, work)
myshixun_ids = homework_common.student_works.pluck(:myshixun_id)
myshixuns = Myshixun.where(id: myshixun_ids).includes(games: [:outputs])
myshixuns = Myshixun.where(id: myshixun_ids).includes(:games)
#student_works_user_id = homework_common.student_works.pluck(:user_id).uniq
#shixun = homework_common.shixuns.first
#logger.info("#########shixun_id: ###{shixun.id}")
@ -54,13 +54,13 @@ module StudentWorksHelper
objects =
myshixuns.map do |myshixun|
# 评测次数
evaluate_count = myshixun.games.inject(0) {|sum, g| sum + g.outputs.pluck(:query_index).first.to_i}
evaluate_count = myshixun.games.sum(:evaluate_count)
# 获取最大评测次数
max_evaluate_count = (evaluate_count > max_evaluate_count ? evaluate_count : max_evaluate_count)
# 通关耗时
pass_consume_time = (myshixun.games.where(status: 2).pluck(:cost_time).sum / 60.0)
# 总耗时
all_time = (myshixun.games.pluck(:cost_time).sum / 60.0)
all_time = (myshixun.games.sum(:cost_time) / 60.0)
# 通关得分
user_total_score = myshixun.total_score.to_i
# 耗时,保留2位小数

@ -7,7 +7,7 @@ class Course < ApplicationRecord
has_many :course_infos, dependent: :destroy
# 课堂左侧导航栏的模块
has_many :course_modules, -> {where hidden: 0}, dependent: :destroy
has_many :course_modules, dependent: :destroy
has_many :board_course_modules, -> { board_module }, class_name: "CourseModule"
has_many :attachment_course_modules, -> { attachment_module }, class_name: "CourseModule"
has_many :common_course_modules, -> { common_homework_module }, class_name: "CourseModule"

@ -7,6 +7,7 @@ class CourseModule < ApplicationRecord
validates :module_name, length: { maximum: 20 }
scope :not_hidden, -> { where(hidden: 0) }
scope :graduation_module, -> { where(module_type: "graduation") }
scope :graduation_module_not_hidden, -> { graduation_module.where(hidden: 0) }
scope :board_module, -> { where(module_type: 'board') }

@ -260,7 +260,7 @@ class User < ApplicationRecord
# 实训管理员实训合作者、admin
def manager_of_shixun?(shixun)
shixun.shixun_members.exists?(role: [1,2], user_id: id) || admin?
shixun.shixun_members.exists?(role: [1,2], user_id: id) || admin? || business?
end
# 实训管理员

@ -12,7 +12,7 @@ json.courses do
json.is_public course.is_public
json.is_accessible course.is_public == 1 || @user.course_identity(course) < Course::NORMAL
json.is_end course.is_end
json.first_category_url module_url(course.course_modules.first, course)
json.first_category_url module_url(course.course_modules.not_hidden.first, course)
end
end
json.courses_count @courses_count

@ -1,6 +1,9 @@
json.(@base_date, :st, :discusses_count, :game_count, :record_onsume_time, :prev_game, :next_game, :praise_count,
:user_praise, :time_limit, :tomcat_url, :is_teacher, :myshixun_manager, :game, :challenge,
:shixun, :myshixun)
if @shixun.vnc
json.vnc_url @vnc_url
end
json.user do
json.partial! 'users/user', user: @user
json.identity @identity

@ -14,6 +14,7 @@ json.commits commits do |commit|
json.author do
json.id nil
json.login nil
json.image_url "avatars/User/b"
json.name commit["author_name"]
json.email commit["author_email"]
end

@ -4,5 +4,4 @@ json.name user.full_name
json.grade user.grade
# json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开
json.image_url url_to_avatar(user)
json.user_url user_path(user)
json.school user.school_name

@ -4,7 +4,7 @@ json.members_count course.members_count
json.homework_commons_count course.homework_commons_count
json.attachments_count course.attachments.count
json.first_category_url module_url(course.course_modules.where.not(module_type: "activity").where(hidden: 0).order(position: :desc).first, course)
json.first_category_url module_url(course.course_modules.where(hidden: 0).order(position: :desc).first, course)
json.is_public course.is_public
json.can_visited observed_logged_user? || course.can_visited?

@ -0,0 +1,76 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
config.cache_store = :file_store, "#{Rails.root }/files/cache_store/"
# if Rails.root.join('tmp', 'caching-dev.txt').exist?
# config.action_controller.perform_caching = true
#
# config.cache_store = :memory_store
# config.public_file_server.headers = {
# 'Cache-Control' => "public, max-age=#{2.days.to_i}"
# }
# else
# config.action_controller.perform_caching = false
#
# config.cache_store = :null_store
# end
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.action_controller.perform_caching = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.exmail.qq.com',
port: 25,
domain: 'smtp.qq.com',
user_name: 'educoder@trustie.org',
password: 'mAZc9EWbe2Kawaqo2',
authentication: 'login',
enable_starttls_auto: true }
end
Loading…
Cancel
Save