Merge branch 'dev_aliyun' into develop

dev_forum
cxt 5 years ago
commit 3913b5a3ca

@ -11,7 +11,8 @@ class CoursesController < ApplicationController
render_error(ex.model.errors.full_messages.join(','))
end
before_action :require_login, :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner]
before_action :require_login, :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
:left_banner, :top_banner, :apply_to_join_course]
before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt,
:set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers,
:top_banner, :left_banner, :add_teacher_popup, :add_teacher,

@ -7,6 +7,7 @@ class SubjectsController < ApplicationController
:up_member_position, :down_member_position]
include ApplicationHelper
include SubjectsHelper
def index
@tech_system = Repertoire.where(nil).order("updated_at desc")
@ -81,11 +82,13 @@ class SubjectsController < ApplicationController
@is_creator = current_user.creator_of_subject?(@subject)
# 合作团队
@members = @subject.subject_members.includes(:user)
challenge_ids = Challenge.where(shixun_id: @subject.shixuns.published.pluck(:id)).pluck(:id)
shixun_ids = @subject.shixuns.published.pluck(:id)
challenge_ids = Challenge.where(shixun_id: shixun_ids).pluck(:id)
# 实训路径中的所有实训标签
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
# 用户获取的实训标签
@user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
# @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
@user_tags = user_shixun_tags challenge_ids, @user.id
# 访问数变更
@subject.increment!(:visits)

@ -3,6 +3,12 @@ class UsersController < ApplicationController
before_action :load_user, only: [:show, :homepage_info]
before_action :check_user_exist, only: [:show, :homepage_info]
# 检查是否更新
def system_update
@notice = SystemUpdateNotice.last
end
def show;end
def update

@ -10,4 +10,9 @@ module SubjectsHelper
end
status
end
# 实训路径的所有用户获得的标签
def user_shixun_tags challenge_ids, user_id
ChallengeTag.joins(challenge: [:games]).where(games: {status: 2, user_id: user_id}, challenges: {id:challenge_ids}).pluck("challenge_tags.name").uniq
end
end

@ -1,5 +1,5 @@
class ChallengeChoose < ApplicationRecord
default_scope {order("position asc")}
default_scope {order("challenge_chooses.position asc")}
belongs_to :challenge, optional: true
has_many :challenge_tags, :dependent => :destroy
has_many :challenge_questions, dependent: :destroy

@ -56,6 +56,7 @@ class Shixun < ApplicationRecord
scope :visible, -> { where.not(status: -1) }
scope :published, lambda{ where(status: 2) }
scope :published_closed, lambda{ where(status: [2, 3]) }
scope :unhidden, lambda{ where(hidden: 0, status: 2) }
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }
scope :find_by_ids,lambda{|k| where(id:k)}

@ -53,11 +53,13 @@ class Subject < ApplicationRecord
end
def my_subject_score
shixuns_id = self.stage_shixuns.map(&:shixun_id)
shixuns_id = Shixun.where(:id => shixuns_id, :status =>[2, 3]).map(&:id)
shixuns_id = shixuns_id.present? ? shixuns_id.join(",") : -1
my_shixun_score = Challenge.find_by_sql("select sum(c.score) as score FROM challenges c join games g on g.challenge_id = c.id where g.status = 2 and g.user_id = #{User.current.id} and c.shixun_id in(#{shixuns_id})").first.try(:score)
my_choose_score = ChallengeChoose.find_by_sql("SELECT sum(g.final_score) score FROM (`challenge_chooses` cc join challenges c on cc.challenge_id = c.id) join games g on g.challenge_id = c.id where g.status = 2 and g.user_id = #{User.current.id} and c.shixun_id in(#{shixuns_id})").first.try(:score)
# shixuns_id = @subject.shixuns.published_closed.pluck(:id)
# shixuns_id = shixuns_id.present? ? shixuns_id.join(",") : -1
shixuns_id = shixuns.published_closed.pluck(:id)
my_shixun_score = Challenge.joins(:games).where(games: {status: 2, user_id: User.current.id}, shixun_id: shixuns_id).pluck(:score).sum
# my_shixun_score = Challenge.find_by_sql("select sum(c.score) as score FROM challenges c join games g on g.challenge_id = c.id where g.status = 2 and g.user_id = #{User.current.id} and c.shixun_id in(#{shixuns_id})").first.try(:score)
my_choose_score = ChallengeChoose.joins(challenge: :games).where(games: {status: 2, user_id: User.current.id}, challenges: {shixun_id: shixuns_id}).pluck(:score).sum
# my_choose_score = ChallengeChoose.find_by_sql("SELECT sum(g.final_score) score FROM (`challenge_chooses` cc join challenges c on cc.challenge_id = c.id) join games g on g.challenge_id = c.id where g.status = 2 and g.user_id = #{User.current.id} and c.shixun_id in(#{shixuns_id})").first.try(:score)
return my_shixun_score.to_i + my_choose_score.to_i
end

@ -0,0 +1,2 @@
class SystemUpdateNotice < ApplicationRecord
end

@ -0,0 +1,7 @@
if @notice && @notice.end_time > Time.now
json.system_update true
json.system_score @notice.notes.rstrip
json.(@notice, :subject, :start_time, :end_time)
else
json.system_update false
end

@ -64,6 +64,7 @@ Rails.application.routes.draw do
get :search_user_projects
post :brief_introduction
post :attendance
get :system_update
resource :trial_apply, only: [:create]
resources :projects, only: [] do

@ -1,5 +1,5 @@
class AddTsMemForOutputs < ActiveRecord::Migration[5.2]
def change
add_column :outputs, :ts_mem, :float
#add_column :outputs, :ts_mem, :float
end
end

@ -1,5 +1,5 @@
class AddTsTimeForOutputs < ActiveRecord::Migration[5.2]
def change
add_column :outputs, :ts_time, :float
#add_column :outputs, :ts_time, :float
end
end

@ -0,0 +1,11 @@
class ModifyAnswerForChallenges < ActiveRecord::Migration[5.2]
def change
challenges = Challenge.where("answer is not null or answer != ''")
.includes(:challenge_answers).unscoped
challenges.find_each do |c|
next if c.challenge_answers.present?
puts("############challenge_id:##{c.id}")
ChallengeAnswer.create(name: "解题代码", contents: "#{c.answer}", level: 1, score: 100, challenge_id: c.id)
end
end
end

@ -1,66 +1,62 @@
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
.rails-default-error-page {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
<meta charset="utf-8">
<title>EduCoder 500 error</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/educoder/edu-main.css" />
<link href="//at.alicdn.com/t/font_653600_rr8l5v2aaym.css" rel="stylesheet" type="text/css"/>
<script src="/javascripts/jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js"></script>
.rails-default-error-page div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
<style type="text/css">
body {
font-family: "微软雅黑","宋体";
background: #fff;
}
.rails-default-error-page div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
h1 {
font-size: 1.5em;
}
.rails-default-error-page h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
p {
font-size: 0.8em;
}
.rails-default-error-page div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
.h_content{
text-align: center;
padding-top: 15px;
}
.font_h{
font-size: 24px;
color: #ff0077;
}
.verticalCenter{
height: 100%;
justify-content: center;
align-items: center;
display: -webkit-flex;
}
</style>
<script type="text/javascript">
$(function(){
if(window.history.length == 1)
{
$("#history_back").css("color","#CCC");
$("#history_back").css("cursor","default");
}
});
</script>
</head>
<body class="rails-default-error-page">
<!-- This file lives in public/500.html -->
<div class="dialog">
<div>
<h1>We're sorry, but something went wrong.</h1>
<body>
<!-- <h1>Internal error</h1>
<p>An error occurred on the page you were trying to access.<br />
If you continue to experience problems please contact your Trustie administrator for assistance.</p>
<p>If you are the Trustie administrator, check your log files for details about the error.</p> -->
<div class="verticalCenter">
<div class="edu-txt-center">
<img src="/images/warn/pic_500.jpg" >
<p class="font-18 mt40">您可以稍后尝试&nbsp;
您可以稍后尝试&nbsp;<a href="javascript:history.back()" class="color-blue">返回上页</a>,或者&nbsp;
<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=2f2043d88c1bd61d182b98bf1e061c6185e23055bec832c07d8148fe11c5a6cd" class="color-blue">QQ反馈>></a>
</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe SystemUpdateNotice, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Loading…
Cancel
Save