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

online_time
caicai8 5 years ago
commit 9aa7a7082f

@ -368,6 +368,7 @@ class HomeworkCommonsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@homework = HomeworkCommon.new(homework_params)
@homework.reference_answer = params[:reference_answer].to_s.strip
@homework.homework_type = @homework_type
@homework.user_id = current_user.id
@homework.course_id = @course.id
@ -417,6 +418,7 @@ class HomeworkCommonsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@homework.update_attributes!(homework_params)
@homework.reference_answer = params[:reference_answer].to_s.strip
if @homework.homework_type == "group"
homework_detail_group = @homework.homework_detail_group
@ -1404,8 +1406,8 @@ class HomeworkCommonsController < ApplicationController
end
def homework_params
tip_exception("name参数不能为空") if params[:name].blank?
tip_exception("description参数不能为空") if params[:description].blank?
tip_exception("标题不能为空") if params[:name].blank?
tip_exception("内容不能为空") if params[:description].blank?
params.require(:homework_common).permit(:name, :description, :reference_answer)
end

@ -19,6 +19,13 @@ class MainController < ApplicationController
uid_logger("main start is #{cookies[:_educoder_session]}")
end
render file: 'public/react/build/index.html', :layout => false
if params[:path] && params[:path]&.include?("educoderh5") && params[:path].split("/").first == "educoderh5"
render file: 'public/h5build/index.html', :layout => false
else
render file: 'public/react/build/index.html', :layout => false
end
end
end

@ -25,7 +25,7 @@ class ShixunsController < ApplicationController
before_action :special_allowed, only: [:send_to_course, :search_user_courses]
before_action :shixun_marker, only: [:new, :create]
before_action :validate_wachat_support, only: [:shixun_exec]
#before_action :validate_wachat_support, only: [:shixun_exec]
skip_before_action :check_sign, only: [:download_file]
## 获取课程列表
@ -1186,11 +1186,11 @@ private
md5.hexdigest
end
def validate_wachat_support
if (params[:wechat].present? && !@shixun.is_wechat_support?)
tip_exception(-5, "..")
end
end
# def validate_wachat_support
#
# if (params[:wechat].present? && !@shixun.is_wechat_support?)
# tip_exception(-5, "..")
# end
# end
end

@ -0,0 +1,23 @@
class Weapps::ChallengesController < Weapps::BaseController
before_action :require_login
before_action :set_challenge
def is_play
# 关卡有展示效果 || 选择题 || jupyter实训 || vnc || 隐藏代码窗口 || html+css实训
play = @challenge.show_type != -1 || @challenge.st == 1 || @shixun.is_jupyter? || @shixun.vnc ||
@shixun.hide_code? || (@shixun.small_mirror_name & ["Css", "Html", "Web"]).present?
if play
normal_status(-5, "该关卡暂不支持小程序")
else
render_ok
end
end
private
def set_challenge
@challenge = Challenge.find_by!(id: params[:id])
@shixun = @challenge.shixun
end
end

@ -17,7 +17,13 @@ class Weapps::SessionsController < Weapps::BaseController
# session[:wechat_user_extra].delete(:nickName)
# 绑定微信号
OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank?
# open_user = OpenUsers::Wechat.find_by(uid: session_unionid)
# if open_user.present? && open_user.user_id.nil?
# open_user.update!(user_id: user.id)
# els
if user.wechat_open_user.blank?
OpenUsers::Wechat.create!(user: user, uid: session_unionid)
end
successful_authentication(user)
end

@ -0,0 +1,16 @@
class Weapps::UnbindAccountsController < Weapps::BaseController
before_action :require_login
def show
@user = current_user
end
def destroy
open_user = OpenUsers::Wechat.find_by!(user_id: current_user.id)
session[:unionid] = open_user.uid
open_user.destroy!
UserAction.create(action_id: current_user.id, action_type: "UnbindWechat", user_id: current_user.id, :ip => request.remote_ip)
logout_user
render_ok
end
end

@ -171,10 +171,10 @@ module HomeworkCommonsHelper
{status: status, time: time}
end
# 作品数统计type 1 已提交 0 未提交
# 作品数统计type 1 已提交 0 未提交 2 所有
def studentwork_count homework_common, type, member
student_works = homework_common.teacher_works(member)
type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size
type == 2 ? student_works.size : (type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size)
end
# 上次查重的时间

@ -1,15 +1,16 @@
module Weapps::CoursesHelper
require 'chinese_pinyin'
def teacher_list teachers
def teacher_list teachers, user_course_identity
data = []
teachers.each do |teacher|
if teacher.user.present?
teacher_user = teacher.user
name = teacher_user.real_name
role = teacher.role == "CREATOR" ? "管理员" : teacher.role == "PROFESSOR" ? "教师" : "助教"
member_roles = user_course_identity < Course::ASSISTANT_PROFESSOR ? teacher_user.course_role(teacher.course) : []
item = {name: name, course_member_id: teacher.id, login: teacher_user.login, user_id: teacher.user_id, role: role,
school: teacher_user.school_name, image_url: url_to_avatar(teacher_user)}
school: teacher_user.school_name, image_url: url_to_avatar(teacher_user), member_roles: member_roles}
pinyin = Pinyin.t(name.strip, splitter: '')
first_char = pinyin[0]
letter = first_letter first_char
@ -28,15 +29,16 @@ module Weapps::CoursesHelper
end
def student_list students, excellent
def student_list students, excellent, user_course_identity
data = []
students.each do |student|
if student.user.present?
student_user = student.user
name = student_user.real_name
phone = excellent ? "" : student_user.hidden_phone
member_roles = user_course_identity < Course::ASSISTANT_PROFESSOR ? student_user.course_role(student.course) : []
item = {name: name, course_member_id: student.id, login: student_user.login, user_id: student.user_id,
student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone}
student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone, member_roles: member_roles}
pinyin = Pinyin.t(name.strip, splitter: '')
first_char = pinyin[0]
letter = first_letter first_char

@ -35,7 +35,7 @@ class HomeworkCommon < ApplicationRecord
# 学生的查重情况
has_many :homework_review_results, :dependent => :destroy
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" }
validates :explanation, length: { maximum: 5000, too_long: "不能超过5000个字符" }
validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" }

@ -8,6 +8,7 @@ class MirrorRepository < ApplicationRecord
scope :published_mirror, -> { where(status: [1,2,3,5]) }
scope :published_main_mirror, -> { published_mirror.where(main_type: 1) }
scope :published_small_mirror, -> { published_mirror.where(main_type: 0) }
scope :small_mirror, -> { where(main_type: 0) }
def deletable?
status != 1 && !shixun_mirror_repositories.exists?

@ -171,7 +171,8 @@ class Shixun < ApplicationRecord
# 实训对应的镜像小类别名(已选)
def small_mirror_name
mirror_repositories.published_small_mirror.map(&:type_name)
names = mirror_repositories.small_mirror.map(&:type_name)
names.blank? ? [] : names
end
def small_mirror_id

@ -27,21 +27,20 @@ json.homeworks @homework_commons.each do |homework|
unless curr_status[:status].include?("未发布")
json.commit_count studentwork_count homework, 1, @member
json.uncommit_count studentwork_count homework, 0, @member
json.all_count studentwork_count homework, 2, @member
end
if @user_course_identity < Course::STUDENT
if homework.homework_type == "practice"
json.shixun_identifier homework.shixuns.take.try(:identifier)
json.shixun_status homework.shixuns.take.try(:status).to_i
end
elsif @user_course_identity == Course::STUDENT
if homework.homework_type == "practice"
json.shixun_identifier homework.shixuns.take.try(:identifier)
json.shixun_status homework.shixuns.take.try(:status).to_i
end
if @user_course_identity == Course::STUDENT
if homework.homework_type == "practice"
shixun = homework.shixuns.take
# json.challenge_count homework.shixuns.first.try(:challenges_count).to_i
current_myshixun = homework.user_work(@user.id).try(:myshixun)
myshixun = current_myshixun ? current_myshixun : shixun.myshixuns.find_by(user_id: @user.id)
# json.game_count current_myshixun ? current_myshixun.exec_count : 0
json.shixun_status shixun.try(:status).to_i
json.task_operation task_operation_url(myshixun, shixun)
else
work = homework.user_work(@user.id)

@ -1,4 +1,4 @@
json.students student_list @students, @course.excellent
json.students student_list @students, @course.excellent, @user_course_identity
json.students_count @students_count
if @course_group
json.course_group do

@ -1,3 +1,3 @@
json.teacher_list teacher_list(@teacher_list)
json.teacher_list teacher_list(@teacher_list, @user_course_identity)
json.teacher_list_size @teacher_list_size
json.apply_size @applications_size

@ -0,0 +1 @@
json.user_account @user.phone.present? ? @user.phone : (@user.mail.present? ? @user.mail : @user.login)

@ -1019,6 +1019,7 @@ Rails.application.routes.draw do
resource :code_session, only: [:create]
resource :verify, only: [:create]
resource :check_account, only: [:create]
resource :unbind_accounts, only: [:show, :destroy]
resources :searchs, only: [:index]
resources :course_stickies, only: [:create] do
@ -1027,6 +1028,9 @@ Rails.application.routes.draw do
resources :shixun_lists, only: [:index]
resources :subjects, path: :paths, only: [:index, :create, :update, :edit, :show]
resources :challenges do
get :is_play, on: :member
end
resources :courses, only: [:create, :update, :edit, :show] do
member do

@ -5,9 +5,9 @@
<title>EduCoder</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css" href="/stylesheets/css/edu-common.css?1">
<link rel="stylesheet" type="text/css" href="/stylesheets/educoder/edu-main.css?1">
<link rel="stylesheet" type="text/css" href="/stylesheets/educoder/edu-all.css?1">
<link rel="stylesheet" type="text/css" href="/stylesheets/css/edu-common.css?2">
<link rel="stylesheet" type="text/css" href="/stylesheets/educoder/edu-main.css?2">
<link rel="stylesheet" type="text/css" href="/stylesheets/educoder/edu-all.css?2">
</head>
<body style="" data-gr-c-s-loaded="true">

@ -15,7 +15,7 @@
text-align: center;
height: 60px;
box-sizing: border-box;
min-width: 785px;
min-width: 780px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

@ -828,7 +828,7 @@ class App extends Component {
render={
(props) => (<Headplugselection {...this.props} {...props} {...this.state} />)
}/>
<Route path="/wxcode/:identifier?" component={WXCode}
<Route path="/wxcode/:identifier?" component={WXCode}
render={
(props)=>(<WXCode {...this.props} {...props} {...this.state}></WXCode>)
}

@ -46,7 +46,7 @@ if (isDev) {
// 老师
//debugType="teacher";
// 学生
//debugType="student";
debugType="student";

@ -10,10 +10,10 @@ import tencent from './images/tencent.png';
import WeiBaiTong from './images/WeiBaiTong.png';
import douyu from './images/douyu.jpg';
class Live extends Component{
render(){
const { liveData , lives , successFunc , pageSize , changePage , page } = this.props;
return(
<div className="livePanel">
<p className="mt30 mb10 color-grey-9 pl10">EduCoder支持所有第三方直播平台特别推荐</p>
@ -37,9 +37,9 @@ class Live extends Component{
<a href="https://www.douyu.com/special/guide/anchor" target="_blank" className="color-blue ml20">(简明手册)</a>
</li>
<li>
<a href="https://vbconsole.zznode.com/download" target="_blank"><img alt="" src={WeiBaiTong} className="mr8" width="28px"/>
<label className="color-grey-3 pointer">威佰通</label>
</a>
<div><img alt="" src={WeiBaiTong} className="mr8" width="28px"/>
<label className="color-grey-3">威佰通</label>
</div>
<a href="https://www.educoder.net/forums/3734" target="_blank" className="color-blue ml20">(简明手册)</a>
</li>
</ul>
@ -51,11 +51,11 @@ class Live extends Component{
{
lives.map((item,key)=>{
return(
<LiveItem
<LiveItem
key={key}
item={item}
{...this.props}
{...this.state}
item={item}
{...this.props}
{...this.state}
successFunc={()=>successFunc()}
></LiveItem>
)
@ -74,7 +74,7 @@ class Live extends Component{
// <div className="edu-back-white">
// <NoneData style={{width: '100%'}}></NoneData>
// </div>
}
}
</div>
)
}

@ -128,7 +128,7 @@ class ShixunhomeWorkItem extends Component{
stopPro = (event) => {
event.stopPropagation()
}
editname = (name,id,event) => {
this.setState({
ModalsRenametype:true,
@ -373,8 +373,8 @@ class ShixunhomeWorkItem extends Component{
{this.props.isAdmin?<span onClick={(event)=>this.stopPro(event)} className={discussMessage&&discussMessage.shixun_status>1?this.props.isAdminOrCreator()?" newhomepagePostSettingname fr":" homepagePostSettingbox fr":" newwidthSettin fr"} style={{"right":"-2px","top":"6px","display":"block"}}>
{discussMessage&&discussMessage.shixun_status>1?<Link className="btn colorblue font-16 fontweight400 mr20" to={"/shixuns/"+discussMessage.shixun_identifier+"/challenges"} target={"_blank"}>实训详情</Link>:
<a className={"btn colorfff font-16 fontweight400 "}>实训详情</a>
{discussMessage&&discussMessage.shixun_status>1?<Link className="btn colorblue font-16 fontweight400 mr20" to={"/shixuns/"+discussMessage.shixun_identifier+"/challenges"} target={"_blank"}>进入学习</Link>:
<a className={"btn colorfff font-16 fontweight400 "}>进入学习</a>
}
@ -387,27 +387,19 @@ class ShixunhomeWorkItem extends Component{
{this.props.isStudent===true?this.props.course_identity===5?discussMessage&&discussMessage.shixun_status>1?
discussMessage.time_status<5?
<WordsBtn style="blue" className="colorblue font-16 mr20 fr mt2 ">
{startbtn===false?
(discussMessage.task_operation[0] == '继续挑战' || discussMessage.task_operation[0] == '查看实战' ?
<a className="btn colorblue" href={getTaskUrlById(discussMessage.task_operation[1])}>
{discussMessage.task_operation[0]}
</a>
:
<a className="btn colorblue" onClick={()=>this.taskoperationId(discussMessage.task_operation[1])}>
{discussMessage.task_operation[0]}
</a>):<a className="btn colorblue" ></a>}
<Link className="btn colorblue font-16 fontweight400" to={"/shixuns/"+discussMessage.shixun_identifier+"/challenges"} target={"_blank"}>进入学习</Link>
</WordsBtn>:"":"":"":""
}
{ this.props.isAdmin?<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品详情</a>:""}
{ this.props.isAdmin?<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品列表</a>:""}
{
this.props.isStudent? <a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">作品详情</a>:""
this.props.isStudent? <a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">作品列表</a>:""
}
{
this.props.isNotMember===true? this.props.discussMessage.private_icon===true?""
:<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品详情</a>:""
:<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">作品列表</a>:""
}
@ -440,9 +432,9 @@ class ShixunhomeWorkItem extends Component{
{ <div className=" color-grey9 task-hide fr" style={discussMessage.time_status===1||discussMessage.time_status===2||discussMessage.time_status===3||discussMessage.time_status===4||discussMessage.time_status===5||discussMessage.time_status===6?{"maxWidth":"216px"}:{"maxWidth":"550px"}} title={discussMessage.upper_category_name}>所属目录{discussMessage.upper_category_name}</div>}
</ConditionToolTip>
}
{/* { discussMessage.replies_count != 0 && <span className="mr15 color-grey9">{discussMessage.replies_count} </span> }
{ discussMessage.praise_num != 0 && <span className="mr15 color-grey9">{discussMessage.praise_num} 点赞</span> }

@ -4,7 +4,7 @@
* @Github:
* @Date: 2020-01-10 09:33:45
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-14 17:01:32
* @LastEditTime : 2020-02-14 17:51:48
*/
import './index.scss';
import React, { useEffect } from 'react';
@ -166,36 +166,46 @@ const App = (props) => {
{
title: '姓名',
dataIndex: 'username',
align: 'center'
align: 'center',
width: 200
},
{
title: '通关实训数',
dataIndex: 'passed_myshixun_count',
align: 'center',
with: 170,
render: (val) => val + '',
sorter: (a, b) => a.passed_myshixun_count - b.passed_myshixun_count
},
{
title: '完成关卡',
dataIndex: 'passed_games_count',
align: 'center',
with: 170,
render: (val) => val + '',
sorter: (a, b) => a.passed_games_count - b.passed_games_count
},
{
title: '代码行',
dataIndex: 'code_line_count',
align: 'center',
with: 170,
render: (val) => val + '',
sorter: (a, b) => a.code_line_count - b.code_line_count
},
{
title: '评测次数',
dataIndex: 'evaluate_count',
align: 'center',
with: 170,
render: (val) => val + '',
sorter: (a, b) => a.evaluate_count - b.evaluate_count
},
{
title: '所用时间',
dataIndex: 'cost_time',
align: 'center',
// with: 180,
render: (text) => (text && moment(text).format('HH:mm:ss')) || '-',
sorter: (a, b) => a.cost_time - b.cost_time
}

@ -35,14 +35,14 @@ if (!window['indexHOCLoaded']) {
// $('head').append($('<link rel="stylesheet" type="text/css" />')
// .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?1`));
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?3`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?1`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?3`));
// index.html有加载
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?1`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?3`));
// $('head').append($('<link rel="stylesheet" type="text/css" />')

@ -15,7 +15,7 @@
text-align: center;
height: 60px;
box-sizing: border-box;
min-width: 785px;
min-width: 780px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

Loading…
Cancel
Save