mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: pass pdoc with UiContext
This commit is contained in:
1 parent
ec83da1080
commit
19e14fc90f
7 files changed
+23
-26
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.26.6",
|
"version": "2.26.7",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -381,10 +381,7 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
|||||||
@param('additional_file', Types.Boolean)
|
@param('additional_file', Types.Boolean)
|
||||||
@param('pjax', Types.Boolean)
|
@param('pjax', Types.Boolean)
|
||||||
async get(domainId: string, getTestdata = true, getAdditionalFile = true, pjax = false) {
|
async get(domainId: string, getTestdata = true, getAdditionalFile = true, pjax = false) {
|
||||||
const canReadData = this.user.own(this.pdoc)
|
this.response.body.testdata = getTestdata ? sortFiles(this.pdoc.data || []) : [];
|
||||||
|| this.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA)
|
|
||||||
|| this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA);
|
|
||||||
this.response.body.testdata = (getTestdata && canReadData) ? sortFiles(this.pdoc.data || []) : [];
|
|
||||||
this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : [];
|
this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : [];
|
||||||
if (pjax) {
|
if (pjax) {
|
||||||
const { testdata, additional_file } = this.response.body;
|
const { testdata, additional_file } = this.response.body;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.8.20",
|
"version": "4.8.21",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -251,8 +251,7 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
loadSubjective();
|
loadSubjective();
|
||||||
|
|
||||||
if (pagename === 'contest_detail_problem') return;
|
if (pagename === 'contest_detail_problem') return;
|
||||||
const data = await request.get('');
|
UiContext.pdoc.stats = UiContext.pdoc.stats || {};
|
||||||
data.pdoc.stats = data.pdoc.stats || {};
|
|
||||||
const $status = document.getElementById('submission-status-placeholder');
|
const $status = document.getElementById('submission-status-placeholder');
|
||||||
const statusChart = echarts.init($status);
|
const statusChart = echarts.init($status);
|
||||||
statusChart.setOption({
|
statusChart.setOption({
|
||||||
@@ -264,20 +263,20 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
radius: [10, 70],
|
radius: [10, 70],
|
||||||
roseType: 'radius',
|
roseType: 'radius',
|
||||||
data: [
|
data: [
|
||||||
{ value: data.pdoc.stats.TLE, name: 'TLE' },
|
{ value: UiContext.pdoc.stats.TLE, name: 'TLE' },
|
||||||
{ value: data.pdoc.stats.AC, name: 'AC' },
|
{ value: UiContext.pdoc.stats.AC, name: 'AC' },
|
||||||
{ value: data.pdoc.stats.MLE, name: 'MLE' },
|
{ value: UiContext.pdoc.stats.MLE, name: 'MLE' },
|
||||||
{ value: data.pdoc.stats.WA, name: 'WA' },
|
{ value: UiContext.pdoc.stats.WA, name: 'WA' },
|
||||||
{ value: data.pdoc.stats.RE, name: 'RE' },
|
{ value: UiContext.pdoc.stats.RE, name: 'RE' },
|
||||||
{ value: data.pdoc.stats.CE, name: 'CE' },
|
{ value: UiContext.pdoc.stats.CE, name: 'CE' },
|
||||||
{ value: data.pdoc.stats.SE, name: 'SE' },
|
{ value: UiContext.pdoc.stats.SE, name: 'SE' },
|
||||||
{ value: data.pdoc.stats.IGN, name: 'IGN' },
|
{ value: UiContext.pdoc.stats.IGN, name: 'IGN' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const $score = document.getElementById('submission-score-placeholder');
|
const $score = document.getElementById('submission-score-placeholder');
|
||||||
const x = Array.from({ length: 101 }, (v, i) => i).filter((i) => data.pdoc.stats[`s${i}`]);
|
const x = Array.from({ length: 101 }, (v, i) => i).filter((i) => UiContext.pdoc.stats[`s${i}`]);
|
||||||
const scoreChart = echarts.init($score);
|
const scoreChart = echarts.init($score);
|
||||||
scoreChart.setOption({
|
scoreChart.setOption({
|
||||||
tooltip: { trigger: 'item' },
|
tooltip: { trigger: 'item' },
|
||||||
@@ -285,7 +284,7 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
|||||||
yAxis: {},
|
yAxis: {},
|
||||||
series: [{
|
series: [{
|
||||||
data: x.map((i) => ({
|
data: x.map((i) => ({
|
||||||
value: data.pdoc.stats[`s${i}`],
|
value: UiContext.pdoc.stats[`s${i}`],
|
||||||
itemStyle: { color: getScoreColor(i) },
|
itemStyle: { color: getScoreColor(i) },
|
||||||
})),
|
})),
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
|
|||||||
@@ -27,7 +27,11 @@
|
|||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<td class="col--name">
|
<td class="col--name">
|
||||||
<a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name, query:{type:'testdata'} }) }}">{{ file.name }}</a>
|
{% if handler.user.own(pdoc) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) %}
|
||||||
|
<a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name, query:{type:'testdata'} }) }}">{{ file.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<p>{{ file.name }}</p>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="col--size">{{ size(file.size) }}</td>
|
<td class="col--size">{{ size(file.size) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -35,10 +39,6 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if handler.user.own(pdoc) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) %}
|
{{ nothing.render('No testdata at current.') }}
|
||||||
{{ nothing.render('No testdata at current.') }}
|
|
||||||
{% else %}
|
|
||||||
{{ nothing.render("You don't have permission to read testdata.")}}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if page_name != 'problem_detail' %}
|
{% if page_name != 'problem_detail' and page_name != 'homework_detail_problem' %}
|
||||||
<div class="section side">
|
<div class="section side">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Information') }}</h1>
|
<h1 class="section__title">{{ _('Information') }}</h1>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
postPretestUrl: url('problem_pretest', pid=pdoc.docId),
|
postPretestUrl: url('problem_pretest', pid=pdoc.docId),
|
||||||
pretestConnUrl: "/conn/pretest?pid=" + pdoc.pid|default(pdoc.docId) + "&domainId=" + handler.domainId,
|
pretestConnUrl: "/conn/pretest?pid=" + pdoc.pid|default(pdoc.docId) + "&domainId=" + handler.domainId,
|
||||||
codeLang: handler.user.codeLang,
|
codeLang: handler.user.codeLang,
|
||||||
codeTemplate: handler.user.codeTemplate
|
codeTemplate: handler.user.codeTemplate,
|
||||||
|
pdoc: pdoc
|
||||||
}) }}
|
}) }}
|
||||||
{% if tdoc %}
|
{% if tdoc %}
|
||||||
{{ set(UiContext, 'postSubmitUrl', url('contest_detail_problem_submit' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem_submit', pid=pdoc.docId, tid=tdoc.docId)) }}
|
{{ set(UiContext, 'postSubmitUrl', url('contest_detail_problem_submit' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem_submit', pid=pdoc.docId, tid=tdoc.docId)) }}
|
||||||
|
|||||||
Reference in new issue
Block a user