Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_local_cqdsj
杨树林 5 years ago
commit 6d04519e2b

@ -126,7 +126,7 @@ module StudentWorksHelper
if game.status == 2 if game.status == 2
"评测通过" "评测通过"
else else
"共有#{game.challenge.challenge_chooses.count}组测试集,其中有#{game.challenge.challenge_chooses.count-game.choose_correct_num}组测试结果不匹配" "共有#{game.challenge.challenge_chooses.count}组测试集,其中有#{game.challenge.challenge_chooses.count-game.choose_correct_num(output.query_index)}组测试结果不匹配"
end end
end end
end end

@ -6,24 +6,21 @@ class SyncTrustieJob < ApplicationJob
def perform(type, count) def perform(type, count)
Rails.logger.info("#######_________response__sync__start__#########") Rails.logger.info("#######_________response__sync__start__#########")
configs_content = Rails.application.config_for(:configuration)
token = configs_content["sync_token"] token = EduSetting.get('trustie_api_token')
token_url = configs_content["sync_url"] api_host = EduSetting.get('trustie_api_url')
url = "#{token_url}/api/v1/homes/sync_count"
url = "#{api_host}/api/v1/homes/sync_count"
sync_json = { sync_json = {
"token": token, "token": token,
"type": type, "type": type,
"number": count "number": count
} }
uri = URI.parse(url) uri = URI.parse(url)
http = Net::HTTP.new(uri.hostname, uri.port) if api_host
if token_url.include?("https://") http = Net::HTTP.new(uri.hostname, uri.port)
http.use_ssl = true http.send_request('PUT', uri.path, sync_json.to_json, {'Content-Type' => 'application/json'})
Rails.logger.info("#######_________response__sync__end_____#########")
end end
response = http.send_request('PUT', uri.path, sync_json.to_json, {'Content-Type' => 'application/json'})
Rails.logger.info("#######_________response__sync__end_____#########{response.body}")
end end
end end

@ -12,4 +12,8 @@ class ApplicationRecord < ActiveRecord::Base
def display_extra_data(key) def display_extra_data(key)
_extra_data&.[](key) _extra_data&.[](key)
end end
def allow_sync_to_trustie?
Rails.env.production? && EduSetting.get('host_name') == 'https://www.educoder.net'
end
end end

@ -8,7 +8,9 @@ class Project < ApplicationRecord
has_many :issues has_many :issues
has_many :user_grades, dependent: :destroy has_many :user_grades, dependent: :destroy
after_create :sync_project_trustie #同步到trustie after_create do
SyncTrustieJob.perform_later("project", 1) if allow_sync_to_trustie?
end #同步到trustie
# 创建者 # 创建者
def creator def creator
@ -23,7 +25,4 @@ class Project < ApplicationRecord
members.exists?(user_id: user.id) members.exists?(user_id: user.id)
end end
def sync_project_trustie
SyncTrustieJob.perform_later("project", 1)
end
end end

@ -19,7 +19,9 @@ class School < ApplicationRecord
has_many :apply_add_departments, dependent: :destroy has_many :apply_add_departments, dependent: :destroy
has_many :user_extensions, dependent: :nullify has_many :user_extensions, dependent: :nullify
after_create :sync_school_trustie #同步到trustie after_create do
SyncTrustieJob.perform_later("school", 1) if allow_sync_to_trustie? #同步到trustie
end
# 学校管理员 # 学校管理员
def manager?(user) def manager?(user)
@ -41,8 +43,4 @@ class School < ApplicationRecord
def manage_permission?(user) def manage_permission?(user)
manager?(user) || major_manager?(user) || course_manager?(user) manager?(user) || major_manager?(user) || course_manager?(user)
end end
def sync_school_trustie
SyncTrustieJob.perform_later("school", 1)
end
end end

@ -75,7 +75,11 @@ class Shixun < ApplicationRecord
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) } scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }
scope :find_by_ids,lambda{|k| where(id:k)} scope :find_by_ids,lambda{|k| where(id:k)}
after_create :send_tiding, :sync_shixun_trustie #同步到trustie after_create :send_tiding
#同步到trustie
after_create do
SyncTrustieJob.perform_later("practical_training_project", 1) if allow_sync_to_trustie?
end
# REDO:  # REDO: 
def propaedeutics def propaedeutics
@ -290,10 +294,6 @@ class Shixun < ApplicationRecord
subjects.where(hidden: 0).uniq subjects.where(hidden: 0).uniq
end end
def sync_shixun_trustie
SyncTrustieJob.perform_later("practical_training_project", 1)
end
private private
def send_tiding def send_tiding

@ -156,7 +156,9 @@ class User < ApplicationRecord
delegate :gender, :department_id, :school_id, :location, :location_city, :technical_title, to: :user_extension, allow_nil: true delegate :gender, :department_id, :school_id, :location, :location_city, :technical_title, to: :user_extension, allow_nil: true
before_save :update_hashed_password before_save :update_hashed_password
after_create :sync_user_trustie #同步到trustie after_create do
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
end
# #
# validations # validations
@ -314,10 +316,6 @@ class User < ApplicationRecord
shixun.shixun_members.exists?(role: 2, user_id: id) shixun.shixun_members.exists?(role: 2, user_id: id)
end end
def sync_user_trustie
SyncTrustieJob.perform_later("user", 1)
end
# TPI的创建者 # TPI的创建者
def creator_of_game?(game) def creator_of_game?(game)
id == game.user_id id == game.user_id

@ -0,0 +1,8 @@
class InitTrustieConfig < ActiveRecord::Migration[5.2]
def change
hash = {"trustie_api_token" => "", "trustie_api_url" => ""}
hash.each { |key, value|
EduSetting.find_or_create_by(name: key, value: value)
}
end
end

@ -53,14 +53,6 @@ class CompetitionsIndex extends Component{
this.getdata(e.key,page) this.getdata(e.key,page)
}; };
setcompetitonurl=(url)=>{
if(url!=null){
// this.props.history.push(url);
window.location.href=url;
}
}
PaginationCourse=(pageNumber)=>{ PaginationCourse=(pageNumber)=>{
let {category}=this.state; let {category}=this.state;
this.setState({ this.setState({
@ -68,6 +60,7 @@ class CompetitionsIndex extends Component{
}) })
this.getdata(category,pageNumber); this.getdata(category,pageNumber);
} }
render() { render() {
let {datas,page,count}=this.state; let {datas,page,count}=this.state;
@ -124,14 +117,14 @@ class CompetitionsIndex extends Component{
size="large" size="large"
dataSource={datas&&datas} dataSource={datas&&datas}
renderItem={(item,key) => ( renderItem={(item,key) => (
<a target="_blank" href={item.competition_status==="ended"?`/competitions/${item.identifier}/common_header`:item.competition_status==="nearly_published"? this.props.current_user&&this.props.current_user.business===true?`/competitions/${item.identifier}/common_header`:this.props.current_user&&this.props.current_user.admin===true?`/competitions/${item.identifier}/common_header`:null:item.competition_status==="progressing"?`/competitions/${item.identifier}/common_header`:null} <a target="_blank" href={item.competition_status==="ended"?`/competitions/${item.identifier}/common_header`:item.competition_status==="nearly_published"?item.permission.editable==true?`/competitions/${item.identifier}/common_header`:null:item.competition_status==="progressing"?`/competitions/${item.identifier}/common_header`:null}
className={item.competition_status==="ended"?"competitionstitlesshou":item.competition_status==="nearly_published"? className={item.competition_status==="ended"?"competitionstitlesshou":item.competition_status==="nearly_published"?
this.props.current_user&&this.props.current_user.admin===true?"competitionstitlesshou":this.props.current_user&&this.props.current_user.business===true?"competitionstitlesshou":"endedfont":"competitionstitlesshou"} item.permission.editable==true?"competitionstitlesshou":"endedfont":"competitionstitlesshou"}
> >
<div className={"CompetitionsList"} > <div className={"CompetitionsList"} >
{item.competition_status==="nearly_published"? {item.competition_status==="nearly_published"?
this.props.current_user&&this.props.current_user.admin===true?"":this.props.current_user&&this.props.current_user.business===true?"":<div className={"CompetitionsListzhezhao"}>即将发布 敬请期待</div>:""} item.permission.editable==true?"":<div className={"CompetitionsListzhezhao"}>即将发布 敬请期待</div>:""}
{/*<div className={"CompetitionsListzhezhao"}>即将发布 敬请期待</div>*/} {/*<div className={"CompetitionsListzhezhao"}>即将发布 敬请期待</div>*/}
{/*{item.description===null||item.description===undefined||item.description===""?<style>*/} {/*{item.description===null||item.description===undefined||item.description===""?<style>*/}
{/*{*/} {/*{*/}
@ -180,9 +173,9 @@ class CompetitionsIndex extends Component{
> >
<List.Item.Meta <List.Item.Meta
title={<a className={item.competition_status==="ended"?"competitionstitlesshou":item.competition_status==="nearly_published"? title={<a className={item.competition_status==="ended"?"competitionstitlesshou":item.competition_status==="nearly_published"?
this.props.current_user&&this.props.current_user.admin===true?"competitionstitlesshou":this.props.current_user&&this.props.current_user.business===true?"competitionstitlesshou":"endedfont":"competitionstitlesshou"}> item.permission.editable==true?"competitionstitlesshou":"endedfont":"competitionstitlesshou"}>
<a target="_blank" className={"competitionstitles"} <a target="_blank" className={"competitionstitles"}
href={item.competition_status==="ended"?`/competitions/${item.identifier}/common_header`:item.competition_status==="nearly_published"? this.props.current_user&&this.props.current_user.business===true?`/competitions/${item.identifier}/common_header`:this.props.current_user&&this.props.current_user.admin===true?`/competitions/${item.identifier}/common_header`:null:item.competition_status==="progressing"?`/competitions/${item.identifier}/common_header`:null} href={item.competition_status==="ended"?`/competitions/${item.identifier}/common_header`:item.competition_status==="nearly_published"? item.permission.editable==true?`/competitions/${item.identifier}/common_header`:null:item.competition_status==="progressing"?`/competitions/${item.identifier}/common_header`:null}
>{item.name}{item.sub_title===null?"":`——${item.sub_title}`}</a> >{item.name}{item.sub_title===null?"":`——${item.sub_title}`}</a>
{/*<span>{item.sub_title===null?"":*/} {/*<span>{item.sub_title===null?"":*/}
{/*<Tag className="competitionsrelative" color="#87d068">{item.sub_title}</Tag>}*/} {/*<Tag className="competitionsrelative" color="#87d068">{item.sub_title}</Tag>}*/}

@ -1,6 +1,6 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Table, Pagination,Tooltip,Spin, Row, Col ,Tabs} from "antd"; import {Table, Pagination,Tooltip,Spin, Row, Col ,Tabs} from "antd";
import { WordsBtn,on, off, trigger } from 'educoder'; import { WordsBtn,on, off, trigger ,getImageUrl} from 'educoder';
import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom'; import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom';
import axios from'axios'; import axios from'axios';
import './Statistics.css'; import './Statistics.css';
@ -11,14 +11,28 @@ class Statistics extends Component{
this.state={ this.state={
nd1:60, nd1:60,
nd2:40, nd2:40,
nd3:20 nd3:20,
data:undefined
} }
} }
componentDidMount() { componentDidMount() {
this.setState({ this.setState({
isSpin:true, isSpin:true,
})
let courseId=this.props.match.params.coursesId;
let url=`/courses/${courseId}/statistics.json`;
axios.get(url).then((result) => {
if (result) {
this.setState({
data:result.data.top_scores
})
}
}).catch((error) => {
console.log(error);
this.setState({
isSpins:false,
})
}) })
} }
@ -28,7 +42,7 @@ class Statistics extends Component{
} }
render(){ render(){
let {nd1,nd2,nd3}=this.state; let {nd1,nd2,nd3,data}=this.state;
return( return(
<React.Fragment > <React.Fragment >
@ -42,80 +56,148 @@ class Statistics extends Component{
</Row> </Row>
<Row type="flex" justify="center" align="bottom"> <Row type="flex" justify="center" align="bottom">
<Col span={3}> {data&&data.map((item,key)=>{
<li className="pr rankingss"> if(key===3){
<a href="https://test-newweb.educoder.net/users/cao_jl" className="color-dark"> return(
<img src="https://test-newweb.educoder.net/images/avatars/User/g"/> <Col span={3}>
</a> <li className="pr rankingss">
</li> <a href={`/users/${item.user_login}`} className="color-dark">
</Col> <img src={getImageUrl(`images/${item.avatar_url}`)}/>
</a>
<Col span={5}> </li>
<li className="pr rankingss"> </Col>
<a href="https://test-newweb.educoder.net/users/cao_jl" className="color-dark"> )
<img src="https://test-newweb.educoder.net/images/avatars/User/g" className={"mb10"}/> }
</a>
</li> })}
<Col className={`height-${nd2}`}> {data&&data.map((item,key)=>{
if(key===1){
</Col> return(
</Col> <Col span={5}>
<li className="pr rankingss">
<Col span={5} className={"relatives"}> <a href={`/users/${item.user_login}`} className="color-dark">
<li className="pr rankingss"> <img src={getImageUrl(`images/${item.avatar_url}`)} className={"mb10"}/>
<img src="https://test-newweb.educoder.net/images/educoder/huangguan.png" className="huangguans mb5" /> </a>
<a href="https://test-newweb.educoder.net/users/cao_jl" className="color-dark"> </li>
<img src="https://test-newweb.educoder.net/images/avatars/User/g" className={"mb10"}/> <Col className={`height-${nd2}`}>
</a>
</li> </Col>
<Col className={`height-${nd1}`}> </Col>
)
</Col> }
</Col>
})}
<Col span={5}>
<li className="pr rankingss"> {data&&data.map((item,key)=>{
<a href="https://test-newweb.educoder.net/users/cao_jl" className="color-dark"> if(key===0){
<img src="https://test-newweb.educoder.net/images/avatars/User/g" className={"mb10"}/> return(
</a> <Col span={5} className={"relatives"}>
</li> <li className="pr rankingss">
<Col className={`height-${nd3}`}> <img src="https://test-newweb.educoder.net/images/educoder/huangguan.png" className="huangguans mb5" />
<a href={`/users/${item.user_login}`} className="color-dark">
<img src={getImageUrl(`images/${item.avatar_url}`)} className={"mb10 mt5"}/>
</a>
</li>
<Col className={`height-${nd1}`}>
</Col>
</Col>
)
}
})}
{data&&data.map((item,key)=>{
if(key===2){
return(
<Col span={5}>
<li className="pr rankingss">
<a href={`/users/${item.user_login}`} className="color-dark">
<img src={getImageUrl(`images/${item.avatar_url}`)} className={"mb10"}/>
</a>
</li>
<Col className={`height-${nd3}`}>
</Col>
</Col>
)
}
})}
{data&&data.map((item,key)=>{
if(key===4){
return(
<Col span={3}>
<li className="pr rankingss">
<a href={`/users/${item.user_login}`} className="color-dark">
<img src={getImageUrl(`images/${item.avatar_url}`)}/>
</a>
</li>
</Col>
)
}
})}
</Col>
</Col>
<Col span={3}>
<li className="pr rankingss">
<a href="https://test-newweb.educoder.net/users/cao_jl" className="color-dark">
<img src="https://test-newweb.educoder.net/images/avatars/User/g"/>
</a>
</li>
</Col>
</Row> </Row>
<Row className="mt10" type="flex" justify="center" align="bottom"> <Row className="mt10" type="flex" justify="center" align="bottom">
<Col span={3} className={"Statisticscenter"}>
<Col>威震江湖</Col> {data&&data.map((item,key)=>{
<Col>4th</Col> if(key===3){
</Col> return(
<Col span={5} className={"Statisticscenter"}> <Col span={3} className={"Statisticscenter"}>
<Col>神魔遮天</Col> <Col>{item.user_name}</Col>
<Col>2th</Col> <Col>4th</Col>
</Col> </Col>
<Col span={5} className={"Statisticscenter"}> )
<Col>雄霸天下</Col> }
<Col>1th</Col> })}
</Col> {data&&data.map((item,key)=>{
<Col span={5} className={"Statisticscenter"}> if(key===1){
<Col>不灭战神</Col> return(
<Col>3th</Col> <Col span={5} className={"Statisticscenter"}>
</Col> <Col>{item.user_name}</Col>
<Col span={3} className={"Statisticscenter"}> <Col>2th</Col>
<Col>霸气初现</Col> </Col>
<Col>5th</Col> )
</Col> }
})}
{data&&data.map((item,key)=>{
if(key===0){
return(
<Col span={5} className={"Statisticscenter"}>
<Col>{item.user_name}</Col>
<Col>1th</Col>
</Col>
)
}
})}
{data&&data.map((item,key)=>{
if(key===2){
return(
<Col span={5} className={"Statisticscenter"}>
<Col>{item.user_name}</Col>
<Col>3th</Col>
</Col>
)
}
})}
{data&&data.map((item,key)=>{
if(key===4){
return(
<Col span={3} className={"Statisticscenter"}>
<Col>{item.user_name}</Col>
<Col>5th</Col>
</Col>
)
}
})}
</Row> </Row>
</p> </p>
</div> </div>

Loading…
Cancel
Save