Browse Source

Merge branch 'master' of zhaojunzhe/fair-web into master

pull/31/head
richie 5 years ago committed by Gogs
parent
commit
9244ec9a87
  1. 42
      modules/socketio.js
  2. 2
      modules/submission.js
  3. 5
      views/admin_classify.ejs
  4. 20
      views/submission.ejs
  5. 20
      views/submission_contest.ejs

42
modules/socketio.js

@ -27,26 +27,27 @@ function processOverallResult(source, config) {
} }
return { return {
compile: source.compile, compile: source.compile,
judge: config.showDetailResult ? (source.judge && { judge: {
subtasks: source.judge.subtasks && source.judge.subtasks.map(st => ({ subtasks: source.judge && source.judge.subtasks ? source.judge.subtasks.map(st => ({
score: st.score, score: st.score,
cases: st.cases.map(cs => ({ cases: st.cases.map(cs => ({
status: cs.status, status: cs.status,
result: cs.result && { errorMessage: cs.errorMessage,
type: cs.result.type, result: cs.result && {
time: config.showUsage ? cs.result.time : undefined, type: cs.result.type,
memory: config.showUsage ? cs.result.memory : undefined, time: config.showUsage ? cs.result.time : undefined,
scoringRate: cs.result.scoringRate, memory: config.showUsage ? cs.result.memory : undefined,
systemMessage: cs.result.systemMessage, scoringRate: cs.result.scoringRate,
input: config.showTestdata ? cs.result.input : undefined, systemMessage: cs.result.systemMessage,
output: config.showTestdata ? cs.result.output : undefined, input: config.showTestdata ? cs.result.input : undefined,
userOutput: config.showTestdata ? cs.result.userOutput : undefined, output: config.showTestdata ? cs.result.output : undefined,
userError: config.showTestdata ? cs.result.userError : undefined, userOutput: config.showTestdata ? cs.result.userOutput : undefined,
spjMessage: config.showTestdata ? cs.result.spjMessage : undefined, userError: config.showTestdata ? cs.result.userError : undefined,
} spjMessage: config.showTestdata ? cs.result.spjMessage : undefined,
})) }
})) }))
}) : null })) : null
}
}; };
} }
function getCompileStatus(status) { function getCompileStatus(status) {
@ -149,7 +150,8 @@ function initializeSocketIO(s) {
return { return {
ok: true, ok: true,
finished: false, finished: false,
running: false running: false,
result: processOverallResult(finishedJudgeList[taskId], clientDisplayConfigList[socket.id])
}; };
} }
} }

2
modules/submission.js

@ -293,7 +293,7 @@ app.get('/submission/:id', async (req, res) => {
formattedCode: judge.formattedCode ? judge.formattedCode.toString("utf8") : null, formattedCode: judge.formattedCode ? judge.formattedCode.toString("utf8") : null,
preferFormattedCode: res.locals.user ? res.locals.user.prefer_formatted_code : true, preferFormattedCode: res.locals.user ? res.locals.user.prefer_formatted_code : true,
detailResult: processOverallResult(judge.result, currentConfig), detailResult: processOverallResult(judge.result, currentConfig),
socketToken: (judge.task_id != null) ? jwt.sign({ socketToken: (judge.pending && judge.task_id != null) ? jwt.sign({
taskId: judge.task_id, taskId: judge.task_id,
type: 'detail', type: 'detail',
displayConfig: displayConfig displayConfig: displayConfig

5
views/admin_classify.ejs

@ -160,7 +160,6 @@
return !this.disabledId.includes(row.id); return !this.disabledId.includes(row.id);
}, },
toggleSelection(rows) { toggleSelection(rows) {
console.log(rows);
if (rows) { if (rows) {
rows.forEach(row => { rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row); this.$refs.multipleTable.toggleRowSelection(row);
@ -237,7 +236,7 @@
} }
that.disabledId = findDifference(currentIdArray, that.usedProblemId); that.disabledId = findDifference(currentIdArray, that.usedProblemId);
that.multipleSelection = that.problemIdArray; that.multipleSelection = that.problemIdArray;
that.toggleSelection(that.multipleSelection) that.getProblemPagination(1);
that.order = order; that.order = order;
} }
}, },
@ -249,7 +248,6 @@
}, },
show: function(id){ show: function(id){
let that = this; let that = this;
this.getProblemPagination(1);
if (id) { if (id) {
this.classifyId = id; this.classifyId = id;
this.getClassifyInfos(id); this.getClassifyInfos(id);
@ -274,7 +272,6 @@
order: this.order, order: this.order,
problemIdArray: this.multipleSelection.map(item=>item.id) problemIdArray: this.multipleSelection.map(item=>item.id)
} }
console.log(obj.problemIdArray);
if (this.classifyId === -1) { if (this.classifyId === -1) {
$.ajax({ $.ajax({
url: '/api/practice/create', url: '/api/practice/create',

20
views/submission.ejs

@ -351,17 +351,17 @@ if (token != null) {
}); });
socket.emit('join', token, function (data) { socket.emit('join', token, function (data) {
console.log("join! ", data); console.log("join! ", data);
let max=0;
if (data && data.result && data.result.judge) {
data.result.judge.subtasks.forEach(function (item) {
item.cases.forEach(function (one) {
max = one.result.time
});
});
}
if (data && data.ok) { if (data && data.ok) {
if (data.finished) { if (data.finished && data.result && data.result.judge) {
data.roughResult.maxItemTime = max; let max=0;
data.result.judge.subtasks.forEach(function (item) {
item.cases.forEach(function (one) {
max = one.result.time
});
});
if (max !== 0) {
data.roughResult.maxItemTime = max;
}
vueApp.roughData.result = data.roughResult; vueApp.roughData.result = data.roughResult;
// if (!data.result) location.reload(true); // if (!data.result) location.reload(true);
vueApp.detailResult = data.result; vueApp.detailResult = data.result;

20
views/submission_contest.ejs

@ -352,17 +352,17 @@ if (token != null) {
}); });
socket.emit('join', token, function (data) { socket.emit('join', token, function (data) {
console.log("join! ", data); console.log("join! ", data);
let max=0;
if (data && data.result && data.result.judge) {
data.result.judge.subtasks.forEach(function (item) {
item.cases.forEach(function (one) {
max = one.result.time
});
});
}
if (data && data.ok) { if (data && data.ok) {
if (data.finished) { if (data.finished && data.result && data.result.judge) {
data.roughResult.maxItemTime = max; let max=0;
data.result.judge.subtasks.forEach(function (item) {
item.cases.forEach(function (one) {
max = one.result.time
});
});
if (max !== 0) {
data.roughResult.maxItemTime = max;
}
vueApp.roughData.result = data.roughResult; vueApp.roughData.result = data.roughResult;
// if (!data.result) location.reload(true); // if (!data.result) location.reload(true);
vueApp.detailResult = data.result; vueApp.detailResult = data.result;

Loading…
Cancel
Save