Merge branch 'educoder' into develop

# Conflicts:
#	public/react/public/js/js_min_all.js
pre_develop
hjm 6 years ago
commit 6f37fc5030

@ -0,0 +1,93 @@
class MigrateHomeworkEndTime < ActiveRecord::Migration
def up
homework = HomeworkCommon.where(id: 18615).first
if homework.present?
transaction do
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '#{homework.end_time}'").each do |work|
work.work_status = 1
work.late_penalty = 0
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
homework = HomeworkCommon.where(id: 18614).first
if homework.present?
homework.update_column('end_time', '2019-05-20 00:00:00')
transaction do
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-20 00:00:00'").each do |work|
work.work_status = 1
work.late_penalty = 0
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
homework = HomeworkCommon.where(id: 18617).first
if homework.present?
homework.update_column('end_time', '2019-05-29 00:00:00')
homework.save
transaction do
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-05-29 00:00:00'").each do |work|
work.work_status = 1
work.late_penalty = 0
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
homework = HomeworkCommon.where(id: 18616).first
if homework.present?
homework.update_column('end_time', '2019-06-10 00:00:00')
homework.save
transaction do
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-10 00:00:00'").each do |work|
work.work_status = 1
work.late_penalty = 0
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
homework = HomeworkCommon.where(id: 25901).first
if homework.present?
homework.update_column('end_time', '2019-06-16 00:00:00')
homework.save
transaction do
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-16 00:00:00'").each do |work|
work.work_status = 1
work.late_penalty = 0
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
homework = HomeworkCommon.where(id: 25902).first
if homework.present?
homework.update_column('end_time', '2019-06-17 00:00:00')
homework.save
transaction do
homework.student_works.where("work_status = 2 and commit_time is not null and commit_time <= '2019-06-17 00:00:00'").each do |work|
work.work_status = 1
work.late_penalty = 0
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
end
def down
end
end

@ -0,0 +1,31 @@
class MigrateShixunStudentWorkScore2 < ActiveRecord::Migration
def up
homeworks = HomeworkCommon.where(id: [18615, 18614, 18617, 18616, 25901, 25902])
homeworks.each do |homework|
transaction do
homework.student_works.where("work_status > 0").each do |work|
if homework.end_time > Time.now
work.work_status = 1
work.late_penalty = 0
else
myshixun = work.myshixun
if myshixun.status == 1 && myshixun.try(:done_time) < homework.end_time
work.work_status = 1
work.late_penalty = 0
else
work.work_status = 2
work.late_penalty = homework.late_penalty
end
end
score = work.final_score.to_f + work.eff_score.to_f - work.late_penalty.to_f
work.work_score = format("%.2f", score < 0 ? 0 : score.to_f) unless work.ultimate_score
work.save
end
end
end
end
def down
end
end

@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@novnc/novnc": "^1.1.0",
"antd": "^3.6.5",
"autoprefixer": "7.1.6",
"axios": "^0.18.0",

@ -154,8 +154,9 @@ var SHRINK = 1; // 缩小
var repositoryTabHeight = 40
function _resizeTpiPanel () {
$("#game_left_contents").width('400px');
$("#game_right_contents").width( $(".labelN").width() - 400 + 'px');
var _total = $(".labelN").width();
$("#game_left_contents").width( _total * 0.35 + 'px');
$("#game_right_contents").width( _total * 0.65 + 'px');
}
$(function(){
function update_rows_and_cols(rows) {

File diff suppressed because one or more lines are too long

@ -13,7 +13,7 @@ import ChooseEvaluateView from './main/ChooseEvaluateView'
import { CircularProgress } from 'material-ui/Progress';
import Button from 'material-ui/Button';
import VNCDisplay from './VNCDisplay'
import './tpiPage.css';
import './tpiPageForMobile.css';
const $ = window.$;
@ -79,7 +79,11 @@ class MainContent extends Component {
background: #fff;
}
`}</style>
{ showIframeContent ? <iframe src={vnc_url ||"http://106.75.27.125:42288/vnc.html"} id="contentIframe" ></iframe> :
{/* <iframe src={vnc_url ||"http://106.75.27.125:42288/vnc.html"} id="contentIframe" ></iframe> */}
{ showIframeContent && vnc_url ? <VNCDisplay
vnc_url={vnc_url}
></VNCDisplay>
:
<React.Fragment>
{/* 旧版本、评测等待提示--更新提示块*/}
{/*<div className="tip-panel-animate clearfix user_bg_shadow bor-grey-e">

@ -0,0 +1,154 @@
import React, { Component } from 'react';
import RFB from '@novnc/novnc/lib/rfb.js';
const $ = window.$;
// const showIframeContent = window.location.search.indexOf('vnc=1') != -1;
class VNCDisplay extends Component {
componentDidMount() {
console.log(RFB)
let rfb;
let desktopName;
// When this function is called we have
// successfully connected to a server
function connectedToServer(e) {
status("Connected to " + desktopName);
}
// This function is called when we are disconnected
function disconnectedFromServer(e) {
if (e.detail.clean) {
status("Disconnected");
} else {
status("Something went wrong, connection is closed");
}
}
// When this function is called, the server requires
// credentials to authenticate
function credentialsAreRequired(e) {
const password = prompt("Password Required:");
rfb.sendCredentials({ password: password });
}
// When this function is called we have received
// a desktop name from the server
function updateDesktopName(e) {
desktopName = e.detail.name;
}
// Since most operating systems will catch Ctrl+Alt+Del
// before they get a chance to be intercepted by the browser,
// we provide a way to emulate this key sequence.
function sendCtrlAltDel() {
rfb.sendCtrlAltDel();
return false;
}
// Show a status text in the top bar
function status(text) {
document.getElementById('status').textContent = text;
}
// This function extracts the value of one variable from the
// query string. If the variable isn't defined in the URL
// it returns the default value instead.
function readQueryVariable(name, defaultValue) {
// A URL with a query parameter can look like this:
// https://www.example.com?myqueryparam=myvalue
//
// Note that we use location.href instead of location.search
// because Firefox < 53 has a bug w.r.t location.search
const re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
match = document.location.href.match(re);
if (typeof defaultValue === 'undefined') { defaultValue = null; }
if (match) {
// We have to decode the URL since want the cleartext value
return decodeURIComponent(match[1]);
}
return defaultValue;
}
document.getElementById('sendCtrlAltDelButton')
.onclick = sendCtrlAltDel;
// Read parameters specified in the URL query string
// By default, use the host and port of server that served this file
// const host = readQueryVariable('host', window.location.hostname);
// let port = readQueryVariable('port', window.location.port);
// const password = readQueryVariable('password', '');
const { vnc_url } = this.props;
// http://117.50.12.63:43149/vnc_lite.html?password=headless
let _ar1 = vnc_url.split('/');
let ipAndPort = _ar1[2].split(':')
let passwordAr = _ar1[3].split('password=')
const host = ipAndPort[0]
let port = ipAndPort[1]
const password = passwordAr[1].split('&')[0]
const path = readQueryVariable('path', 'websockify');
// | | | | | |
// | | | Connect | | |
// v v v v v v
status("Connecting");
// Build the websocket URL used to connect
let url;
if (window.location.protocol === "https:") {
url = 'wss';
} else {
url = 'ws';
}
url += '://' + host;
if(port) {
url += ':' + port;
}
url += '/' + path;
// Creating a new RFB object will start a new connection
rfb = new RFB(document.getElementById('screen'), url,
{ credentials: { password: password } });
// Add listeners to important events from the RFB module
rfb.addEventListener("connect", connectedToServer);
rfb.addEventListener("disconnect", disconnectedFromServer);
rfb.addEventListener("credentialsrequired", credentialsAreRequired);
rfb.addEventListener("desktopname", updateDesktopName);
// Set parameters that can be changed on an active connection
rfb.viewOnly = readQueryVariable('view_only', false);
rfb.scaleViewport = readQueryVariable('scale', false);
}
render() {
const { challenge, vnc_url } = this.props
return (
<div className="">
<style>{`
#top_bar {
background-color: #6e84a3;
color: white;
font: bold 12px Helvetica;
padding: 6px 5px 4px 5px;
border-bottom: 1px outset;
}
#status {
text-align: center;
}
#sendCtrlAltDelButton {
position: fixed;
top: 0px;
right: 0px;
border: 1px outset;
padding: 5px 5px 4px 5px;
cursor: pointer;
}
#screen {
flex: 1; /* fill remaining space */
overflow: hidden;
}
`}</style>
<div id="top_bar">
<div id="status">Loading</div>
<div id="sendCtrlAltDelButton">Send CtrlAltDel</div>
</div>
<div id="screen"></div>
</div>
);
}
}
export default VNCDisplay;
Loading…
Cancel
Save