mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core&ui: fix contestTimer on duration contest (#576)
This commit is contained in:
1 parent
58cab9919d
commit
5b78afeba5
8 files changed
+15
-6
No files matched your search
@@ -179,9 +179,11 @@ export class ContestDetailHandler extends Handler {
|
||||
async get(domainId: string, tid: ObjectId) {
|
||||
this.response.template = 'contest_detail.html';
|
||||
const udict = await user.getList(domainId, [this.tdoc.owner]);
|
||||
const fields = ['attend', 'startAt'];
|
||||
if (this.tdoc.duration) fields.push('endAt');
|
||||
this.response.body = {
|
||||
tdoc: this.tdoc,
|
||||
tsdoc: pick(this.tsdoc, ['attend', 'startAt']),
|
||||
tsdoc: pick(this.tsdoc, fields),
|
||||
udict,
|
||||
files: sortFiles(this.tdoc.files || []),
|
||||
urlForFile: (filename: string) => this.url('contest_file_download', { tid, filename }),
|
||||
@@ -289,8 +291,9 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
|
||||
const page_name = this.tdoc.rule === 'homework'
|
||||
? 'homework_scoreboard'
|
||||
: 'contest_scoreboard';
|
||||
const tsdoc = pick(this.tsdoc, ['attend', 'startAt', ...(this.tdoc.duration ? ['endAt'] : [])]);
|
||||
this.response.body = {
|
||||
tdoc: this.tdoc, rows, udict, pdict, page_name, groups,
|
||||
tdoc: this.tdoc, tsdoc, rows, udict, pdict, page_name, groups,
|
||||
};
|
||||
this.response.pjax = 'partials/scoreboard.html';
|
||||
this.response.template = 'contest_scoreboard.html';
|
||||
@@ -614,7 +617,7 @@ export class ContestFileDownloadHandler extends ContestDetailBaseHandler {
|
||||
export class ContestUserHandler extends ContestManagementBaseHandler {
|
||||
@param('tid', Types.ObjectId)
|
||||
async get(domainId: string, tid: ObjectId) {
|
||||
const tsdocs = await contest.getMultiStatus(domainId, { docId: tid }).toArray();
|
||||
const tsdocs = await contest.getMultiStatus(domainId, { docId: tid }).project({ uid: 1, attend: 1, startAt: 1 }).toArray();
|
||||
tsdocs.forEach((i) => {
|
||||
i.endAt = (this.tdoc.duration && i.startAt) ? moment(i.startAt).add(this.tdoc.duration, 'hours').toDate() : null;
|
||||
});
|
||||
|
||||
@@ -371,6 +371,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
||||
};
|
||||
if (this.tdoc && this.tsdoc) {
|
||||
const fields = ['attend', 'startAt'];
|
||||
if (this.tdoc.duration) fields.push('endAt');
|
||||
if (contest.canShowSelfRecord.call(this, this.tdoc, true)) fields.push('detail');
|
||||
this.response.body.tsdoc = pick(this.tsdoc, fields);
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ class UserLogoutHandler extends Handler {
|
||||
async post() {
|
||||
this.session.uid = 0;
|
||||
this.session.sudo = null;
|
||||
this.session.sudoUid = null;
|
||||
this.session.scope = PERM.PERM_ALL.toString();
|
||||
this.response.redirect = '/';
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import { tpl } from 'vj/utils';
|
||||
const contestTimer = $(tpl`<pre class="contest-timer" style="display:none"></pre>`);
|
||||
contestTimer.appendTo(document.body);
|
||||
|
||||
export default new NamedPage(['contest_detail', 'contest_detail_problem', 'contest_scoreboard'], () => {
|
||||
const beginAt = new Date(UiContext.tdoc.beginAt).getTime();
|
||||
const endAt = new Date(UiContext.tdoc.endAt).getTime();
|
||||
export default new NamedPage(['contest_detail', 'contest_problemlist', 'contest_detail_problem', 'contest_scoreboard'], () => {
|
||||
const beginAt = new Date((UiContext.tdoc.duration && UiContext.tsdoc?.startAt) || UiContext.tdoc.beginAt).getTime();
|
||||
const endAt = new Date((UiContext.tdoc.duration && UiContext.tsdoc?.endAt) || UiContext.tdoc.endAt).getTime();
|
||||
NProgress.configure({ trickle: false, showSpinner: false, minimum: 0 });
|
||||
function updateProgress() {
|
||||
const now = Date.now();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{% import "components/problem.html" as problem with context %}
|
||||
{% block content %}
|
||||
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||
{{ set(UiContext, 'tsdoc', tsdoc) }}
|
||||
<div class="row">
|
||||
<div class="medium-9 columns">
|
||||
<div class="section">
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{% import "components/problem.html" as problem with context %}
|
||||
{% block content %}
|
||||
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||
{{ set(UiContext, 'tsdoc', tsdoc) }}
|
||||
<div class="row">
|
||||
<div class="medium-9 columns">
|
||||
<div class="section">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% import "components/paginator.html" as paginator with context %}
|
||||
{% extends "layout/basic.html" %}
|
||||
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||
{{ set(UiContext, 'tsdoc', tsdoc) }}
|
||||
{% set type = 'homework' if tdoc.rule == 'homework' else 'contest' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}', query={tid:tdoc.docId})) }}
|
||||
{{ set(UiContext, 'pretestConnUrl', "record-conn?pretest=1&uidOrName=" + handler.user._id + "&pid=" + pdoc.docId + "&domainId=" + handler.args.domainId + "&tid=" + tdoc.docId) }}
|
||||
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||
{{ set(UiContext, 'tsdoc', tsdoc) }}
|
||||
{% else %}
|
||||
{{ set(UiContext, 'canViewRecord', true) }}
|
||||
{{ set(UiContext, 'postSubmitUrl', url('problem_submit', pid=pdoc.docId)) }}
|
||||
|
||||
Reference in new issue
Block a user