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

dev_daiao
杨树林 5 years ago
commit 850d980e9a

@ -1,5 +1,5 @@
.diff{overflow:auto;} .diff{overflow:auto;}
.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;} .diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0 1rem;display:table;width:100%;}
.diff del, .diff ins{display:block;text-decoration:none;} .diff del, .diff ins{display:block;text-decoration:none;}
.diff li{padding:0; display:table-row;margin: 0;height:1em;} .diff li{padding:0; display:table-row;margin: 0;height:1em;}
.diff li.ins{background:#dfd; color:#080} .diff li.ins{background:#dfd; color:#080}

@ -1,13 +1,14 @@
class HackUserLastestCodesController < ApplicationController class HackUserLastestCodesController < ApplicationController
before_action :require_login, except: [:listen_result] before_action :require_login, except: [:listen_result]
before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, :sync_code,
:listen_result, :result, :submit_records, :restore_initial_code] :listen_result, :result, :submit_records, :restore_initial_code]
before_action :update_user_hack_status, only: [:code_debug, :code_submit] before_action :update_user_hack_status, only: [:code_debug, :code_submit]
before_action :require_auth_identity, only: [:update_code, :restore_initial_code] before_action :require_auth_identity, only: [:update_code, :restore_initial_code, :sync_code]
before_action :require_manager_identity, only: [:update_code] before_action :require_manager_identity, only: [:update_code]
def show def show
@my_hack.update_attribute(:submit_status, 0) if @my_hack.submit_status == 1 @my_hack.update_attribute(:submit_status, 0) if @my_hack.submit_status == 1
@modify = @my_hack.modify_time.to_i < @hack.modify_time.to_i
end end
def update_code def update_code
@ -20,6 +21,11 @@ class HackUserLastestCodesController < ApplicationController
@my_hack.update_attribute(:code, @hack.code) @my_hack.update_attribute(:code, @hack.code)
end end
# 同步代码
def sync_code
@my_hack.update_attributes(code: @hack.code, modify_time: @hack.modify_time)
end
# 调试代码 # 调试代码
def code_debug def code_debug
exec_mode = "debug" exec_mode = "debug"

@ -15,7 +15,7 @@ class HacksController < ApplicationController
user_hack.identifier user_hack.identifier
else else
user_identifier = generate_identifier HackUserLastestCode, 12 user_identifier = generate_identifier HackUserLastestCode, 12
user_code = {user_id: current_user.id, code: @hack.code, user_code = {user_id: current_user.id, code: @hack.code, modify_time: Time.now,
identifier: user_identifier, language: @hack.language} identifier: user_identifier, language: @hack.language}
@hack.hack_user_lastest_codes.create!(user_code) @hack.hack_user_lastest_codes.create!(user_code)
user_identifier user_identifier
@ -47,10 +47,8 @@ class HacksController < ApplicationController
hack.identifier = generate_identifier Hack, 8 hack.identifier = generate_identifier Hack, 8
hack.save! hack.save!
# 创建测试集与代码 # 创建测试集与代码
logger.info("hack_sets_params:#{hack_sets_params}")
logger.info("hack_code_params:#{hack_code_params}")
hack.hack_sets.create!(hack_sets_params) hack.hack_sets.create!(hack_sets_params)
hack.hack_codes.create!(hack_code_params) hack.hack_codes.create!(hack_code_params.merge(modify_time: Time.now))
end end
render_ok({identifier: hack.identifier}) render_ok({identifier: hack.identifier})
rescue Exception => e rescue Exception => e
@ -69,6 +67,9 @@ class HacksController < ApplicationController
# 新建 # 新建
@hack.hack_sets.create!(hack_sets_params) @hack.hack_sets.create!(hack_sets_params)
# 更新代码 # 更新代码
if params[:hack_codes][:code] != @hack.code
hack_code_params = hack_code_params.merge(modify_time: Time.now)
end
@hack.hack_codes.create!(hack_code_params) @hack.hack_codes.create!(hack_code_params)
end end
render_ok render_ok

@ -1,13 +1,12 @@
<% if records.present? %> <% if records.present? %>
<% records.each do |record| %> <% records.each do |record| %>
<div class="record-item"> <div class="card mb-5">
<div class="record-item-head font-16"> <div class="card-header font-16">
<span><%= record.user.real_name %></span> <span><%= record.user.real_name %></span>
<span class="ml-3"><%= format_time record.created_at %></span> <span class="ml-3"><%= format_time record.created_at %></span>
</div> </div>
<div class="dropdown-divider"></div>
<div class="record-item-info font-14"> <div class="mt-2 mb-3 ml-3 font-14">
<span>实训名称:<%= record.container&.shixun&.name %></span> <span>实训名称:<%= record.container&.shixun&.name %></span>
<% if record.container_type == "Challenge" %> <% if record.container_type == "Challenge" %>
<span class="ml-3">/</span> <span class="ml-3">/</span>
@ -15,7 +14,7 @@
<% end %> <% end %>
</div> </div>
<div class="diff mt-2 font-12"> <div class="diff font-12">
<ul> <ul>
<% record.diff_record_content&.content&.split("\n").each do |line| %> <% record.diff_record_content&.content&.split("\n").each do |line| %>
<% if line =~ /^[\+]/ %> <% if line =~ /^[\+]/ %>
@ -29,7 +28,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="dropdown-divider"></div>
<% end %> <% end %>
<% else %> <% else %>
<%= render 'admins/shared/no_data_for_table' %> <%= render 'admins/shared/no_data_for_table' %>

@ -5,6 +5,7 @@ json.hack do
json.code @my_hack.code json.code @my_hack.code
json.pass_count @hack.pass_num json.pass_count @hack.pass_num
json.submit_count @hack.submit_num json.submit_count @hack.submit_num
json.modify_code @modify
end end
json.test_case do json.test_case do

@ -59,6 +59,7 @@ Rails.application.routes.draw do
get :result get :result
get :submit_records get :submit_records
post :restore_initial_code post :restore_initial_code
post :sync_code
end end
collection do collection do

@ -0,0 +1,6 @@
class AddModifyTimeForHackCodes < ActiveRecord::Migration[5.2]
def change
add_column :hack_codes, :modify_time, :timestamp
add_column :hack_user_lastest_codes, :modify_time, :timestamp
end
end

File diff suppressed because one or more lines are too long

@ -30,6 +30,13 @@ if (isDev) {
window.location.search.indexOf('debug=s') != -1 ? 'student' : window.location.search.indexOf('debug=s') != -1 ? 'student' :
window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin'
} }
// 超管
// debugType="admin";
// 老师
// debugType="teacher";
// 学生
//debugType="student";
window._debugType = debugType; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {
initOnlineOfflineListener() initOnlineOfflineListener()

@ -1,26 +1,33 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Checkbox,Radio, Input,InputNumber,Spin} from "antd"; import {Input,InputNumber,Spin,Statistic} from "antd";
import '../css/members.css' import '../css/members.css';
import '../css/busyWork.css' import '../css/busyWork.css';
import '../poll/pollStyle.css' import '../poll/pollStyle.css';
import '../css/Courses.css' import '../css/Courses.css';
import moment from 'moment' import moment from 'moment';
import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder' import { WordsBtn,markdownToHTML,ActionBtn,getImageUrl, MarkdownToHtml } from 'educoder';
import Modals from '../../modals/Modals' import Modals from '../../modals/Modals';
import CoursesListType from '../coursesPublic/CoursesListType'; import CoursesListType from '../coursesPublic/CoursesListType';
import Multiple from './question/multiple' import Multiple from './question/multiple';
import Single from './question/single' import Single from './question/single';
import FillEmpty from './question/fillEmpty' import FillEmpty from './question/fillEmpty';
import SimpleAnswer from './question/simpleAnswer' import SimpleAnswer from './question/simpleAnswer';
import ShixunAnswer from './question/shixunAnswer' import ShixunAnswer from './question/shixunAnswer';
import update from 'immutability-helper' import update from 'immutability-helper';
import axios from 'axios'; import axios from 'axios';
import './new/common.css' import './new/common.css';
const { Countdown } = Statistic;
// const deadline = Date.now() + this.state.time*60*60; // Moment is also OK
// console.log(deadline)
const Textarea =Input.TextArea const Textarea =Input.TextArea
const tagArray = [ const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
@ -98,32 +105,37 @@ class ExerciseReviewAndAnswer extends Component{
remainTime=(time)=>{ remainTime=(time)=>{
// let { time } = this.state; // let { time } = this.state;
let h=moment(parseInt(time)*1000).hour()-8; // let h=moment(parseInt(time)*1000).hour()-8;
let m=moment(parseInt(time)*1000).minutes(); // let m=moment(parseInt(time)*1000).minutes();
let s=moment(parseInt(time)*1000).seconds(); // let s=moment(parseInt(time)*1000).seconds();
this.timer = setInterval(() => { // this.timer = setInterval(() => {
if(time>0){ // if(time>0){
if(s==0){ // if(s==0){
if(m > 0){ // if(m > 0){
m--; // m--;
} // }
s=59; // s=59;
}else{ // }else{
s--; // s--;
} // }
// this.setState({
// hour:h,
// minute:m,
// second:s
// })
// if(h==0 && m==0 && s==0){
// clearInterval(this.timer);
// this.autoCommitExercise();
// }
// }else{
// clearInterval(this.timer);
// }
// },1000)
}
autosetimes=(time)=>{
this.setState({ this.setState({
hour:h, time:parseInt(time)
minute:m,
second:s
}) })
if(h==0 && m==0 && s==0){
clearInterval(this.timer);
this.autoCommitExercise();
}
}else{
clearInterval(this.timer);
}
},1000)
} }
//自动交卷 //自动交卷
autoCommitExercise=()=>{ autoCommitExercise=()=>{
@ -146,7 +158,8 @@ class ExerciseReviewAndAnswer extends Component{
} }
if(result.data.status===-2){ if(result.data.status===-2){
this.remainTime(parseInt(result.data.message)) // this.remainTime(parseInt(result.data.message))
this.autosetimes(result.data.message)
} }
} }
}).catch((error)=>{ }).catch((error)=>{
@ -244,7 +257,7 @@ class ExerciseReviewAndAnswer extends Component{
isSpin:false isSpin:false
}) })
if(result.data.exercise.left_time != null){ if(result.data.exercise.left_time != null){
this.remainTime(result.data.exercise.left_time); // this.remainTime(result.data.exercise.left_time);
} }
} }
}).catch((error)=>{ }).catch((error)=>{
@ -571,6 +584,14 @@ class ExerciseReviewAndAnswer extends Component{
this.props.history.push(`/courses/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`) this.props.history.push(`/courses/${coursesId}/exercises/${eId}/student_exercise_list?tab=0`)
} }
deadline=(time)=>{
if(time===null){
}else{
return Date.now() + time * 1000 ;
}
}
render(){ render(){
let coursesId=this.props.match.params.coursesId; let coursesId=this.props.match.params.coursesId;
let eId=this.props.match.params.Id; let eId=this.props.match.params.Id;
@ -613,6 +634,7 @@ class ExerciseReviewAndAnswer extends Component{
const { current_user } = this.props const { current_user } = this.props
// console.log(data&&data.exercise.user_name) // console.log(data&&data.exercise.user_name)
document.title=courseName&&courseName; document.title=courseName&&courseName;
return( return(
<div className="newMain" style={{paddingTop:"0px"}}> <div className="newMain" style={{paddingTop:"0px"}}>
<Spin size="large" spinning={isSpin}> <Spin size="large" spinning={isSpin}>
@ -663,6 +685,7 @@ class ExerciseReviewAndAnswer extends Component{
</p> </p>
<p className="clearfix"> <p className="clearfix">
<span className="color-grey-3 font-24 fl lineh-40" >{exercise && exercise.exercise_name}</span> <span className="color-grey-3 font-24 fl lineh-40" >{exercise && exercise.exercise_name}</span>
<span className="fl mt8"> <span className="fl mt8">
<CoursesListType typelist={[`${statudmap[exercise && exercise.exercise_status]}`]} typesylename={""} /> <CoursesListType typelist={[`${statudmap[exercise && exercise.exercise_status]}`]} typesylename={""} />
</span> </span>
@ -671,15 +694,18 @@ class ExerciseReviewAndAnswer extends Component{
<WordsBtn className="fr font-16 lineh-40" style="grey" onClick={this.returnBtn}>返回</WordsBtn> <WordsBtn className="fr font-16 lineh-40" style="grey" onClick={this.returnBtn}>返回</WordsBtn>
: :
time && time != 0 ? time && time != 0 ?
<div className="fr remainingTime"> <div className="fr">
<li>{ hour >= 10 ? hour : '0'+hour}</li> <Countdown value={this.deadline(this.state.time)} onFinish={this.autoCommitExercise} />
<span>:</span> </div>
<li>{ minute >= 10 ? minute : '0'+minute}</li> :""
<span>:</span>
<li>{ second >= 10 ? second : '0'+second}</li>
</div>:""
} }
{/*<div className="fr remainingTime">*/}
{/* <li>{ hour >= 10 ? hour : '0'+hour}</li>*/}
{/* <span>:</span>*/}
{/* <li>{ minute >= 10 ? minute : '0'+minute}</li>*/}
{/* <span>:</span>*/}
{/* <li>{ second >= 10 ? second : '0'+second}</li>*/}
{/*</div>*/}
{ {
isAdmin && <WordsBtn className="fr font-16 lineh-40 mr30" style="blue" onClick={this.RepeatExercise}>打回重做</WordsBtn> isAdmin && <WordsBtn className="fr font-16 lineh-40 mr30" style="blue" onClick={this.RepeatExercise}>打回重做</WordsBtn>
} }

Loading…
Cancel
Save