Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
c9956d4e
Commit
c9956d4e
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Přehled odevzdaných řešení a feedbacků účastníka + jejich stahování
parent
e8fbdb2f
Branches
Branches containing commit
No related tags found
1 merge request
!9
WIP: Zárodek uživatelské části webu a submitování
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mo/web/org_contest.py
+37
-33
37 additions, 33 deletions
mo/web/org_contest.py
mo/web/util.py
+1
-0
1 addition, 0 deletions
mo/web/util.py
static/mo.css
+6
-0
6 additions, 0 deletions
static/mo.css
with
44 additions
and
33 deletions
mo/web/org_contest.py
+
37
−
33
View file @
c9956d4e
...
@@ -19,6 +19,7 @@ import mo.rights
...
@@ -19,6 +19,7 @@ import mo.rights
from
mo.rights
import
Right
,
Rights
from
mo.rights
import
Right
,
Rights
import
mo.util
import
mo.util
from
mo.web
import
app
from
mo.web
import
app
import
mo.web.util
from
mo.web.util
import
PagerForm
from
mo.web.util
import
PagerForm
from
mo.web.table
import
CellCheckbox
,
Table
,
Column
,
cell_place_link
,
cell_user_link
,
cell_email_link
from
mo.web.table
import
CellCheckbox
,
Table
,
Column
,
cell_place_link
,
cell_user_link
,
cell_email_link
import
wtforms.validators
as
validators
import
wtforms.validators
as
validators
...
@@ -451,14 +452,14 @@ class SolutionContext:
...
@@ -451,14 +452,14 @@ class SolutionContext:
contest
:
db
.
Contest
contest
:
db
.
Contest
round
:
db
.
Round
round
:
db
.
Round
pion
:
db
.
Participation
pion
:
db
.
Participation
user
:
db
.
User
task
:
db
.
Task
task
:
db
.
Task
solution
:
Optional
[
db
.
Solution
]
allow_view
:
bool
allow_view
:
bool
allow_upload_solutions
:
bool
allow_upload_solutions
:
bool
allow_upload_feedback
:
bool
allow_upload_feedback
:
bool
def
get_solution_context
(
contest_id
:
int
,
site_id
:
Optional
[
int
],
user_id
:
int
,
task_id
:
int
)
->
SolutionContext
:
def
get_solution_context
(
contest_id
:
int
,
user_id
:
int
,
task_id
:
int
,
site_id
:
Optional
[
int
]
)
->
SolutionContext
:
sess
=
db
.
get_session
()
sess
=
db
.
get_session
()
# Nejprve zjistíme, zda existuje soutěž
# Nejprve zjistíme, zda existuje soutěž
...
@@ -468,7 +469,8 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
...
@@ -468,7 +469,8 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
# Zkontrolujeme, zda se účastník opravdu účastní soutěže
# Zkontrolujeme, zda se účastník opravdu účastní soutěže
pion
=
(
sess
.
query
(
db
.
Participation
)
pion
=
(
sess
.
query
(
db
.
Participation
)
.
filter_by
(
user_id
=
user_id
,
contest_id
=
contest_id
)
.
filter_by
(
user_id
=
user_id
,
contest_id
=
contest_id
)
.
options
(
joinedload
(
db
.
Participation
.
place
))
.
options
(
joinedload
(
db
.
Participation
.
place
),
joinedload
(
db
.
Participation
.
user
))
.
one_or_none
())
.
one_or_none
())
if
not
pion
:
if
not
pion
:
raise
werkzeug
.
exceptions
.
NotFound
()
raise
werkzeug
.
exceptions
.
NotFound
()
...
@@ -479,14 +481,9 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
...
@@ -479,14 +481,9 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
# Najdeme úlohu a ověříme, že je součástí soutěže
# Najdeme úlohu a ověříme, že je součástí soutěže
task
=
sess
.
query
(
db
.
Task
).
get
(
task_id
)
task
=
sess
.
query
(
db
.
Task
).
get
(
task_id
)
if
not
task
or
task
.
round
_id
!=
round
:
if
not
task
or
task
.
round
!=
round
:
raise
werkzeug
.
exceptions
.
NotFound
()
raise
werkzeug
.
exceptions
.
NotFound
()
# Najdeme řešení úlohy (nemusí existovat)
sol
=
(
sess
.
query
(
db
.
Solution
)
.
filter_by
(
user_id
=
user_id
,
task_id
=
task_id
)
.
one_or_none
())
# Pokud je uvedeno soutěžní místo, hledáme práva k němu, jinak k soutěži
# Pokud je uvedeno soutěžní místo, hledáme práva k němu, jinak k soutěži
if
site_id
is
not
None
:
if
site_id
is
not
None
:
site
=
pion
.
place
site
=
pion
.
place
...
@@ -510,8 +507,8 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
...
@@ -510,8 +507,8 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
contest
=
contest
,
contest
=
contest
,
round
=
round
,
round
=
round
,
pion
=
pion
,
pion
=
pion
,
user
=
pion
.
user
,
task
=
task
,
task
=
task
,
solution
=
sol
,
allow_view
=
allow_view
,
allow_view
=
allow_view
,
allow_upload_solutions
=
allow_upload_solutions
,
allow_upload_solutions
=
allow_upload_solutions
,
allow_upload_feedback
=
allow_upload_feedback
,
allow_upload_feedback
=
allow_upload_feedback
,
...
@@ -519,39 +516,46 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
...
@@ -519,39 +516,46 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
@app.route
(
'
/org/contest/c/<int:contest_id>/submit/<int:user_id>/<int:task_id>/
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/submit/<int:user_id>/<int:task_id>/
'
)
def
org_submit_list
(
contest_id
,
user_id
,
task_id
):
sc
=
get_solution_context
(
contest_id
,
None
,
user_id
,
task_id
)
# FIXME
return
render_template
(
'
not_implemented.html
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/site/<int:site_id>/submit/<int:user_id>/<int:task_id>/
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/site/<int:site_id>/submit/<int:user_id>/<int:task_id>/
'
)
def
org_submit_site_list
(
contest_id
,
site_id
,
user_id
,
task_id
):
def
org_submit_list
(
contest_id
:
int
,
user_id
:
int
,
task_id
:
int
,
site_id
:
Optional
[
int
]
=
None
):
sc
=
get_solution_context
(
contest_id
,
site_id
,
user_id
,
task_id
)
sc
=
get_solution_context
(
contest_id
,
user_id
,
task_id
,
site_id
)
# FIXME
return
render_template
(
'
not_implemented.html
'
)
# Najdeme řešení úlohy (nemusí existovat)
sol
=
(
db
.
get_session
().
query
(
db
.
Solution
)
.
filter_by
(
user_id
=
user_id
,
task_id
=
task_id
)
.
one_or_none
())
@app.route
(
'
/org/contest/c/<int:contest_id>/paper/<int:paper_id>/
'
)
papers
=
(
db
.
get_session
().
query
(
db
.
Paper
)
def
org_submit_paper
(
contest_id
,
paper_id
):
.
filter_by
(
for_user_obj
=
sc
.
user
,
task
=
sc
.
task
)
# sc = get_solution_context(contest_id, None, user_id, task_id)
.
options
(
joinedload
(
db
.
Paper
.
uploaded_by_obj
))
.
order_by
(
db
.
Paper
.
uploaded_at
.
desc
())
.
all
())
# FIXME
sol_papers
=
[
p
for
p
in
papers
if
p
.
type
==
db
.
PaperType
.
solution
]
fb_papers
=
[
p
for
p
in
papers
if
p
.
type
==
db
.
PaperType
.
feedback
]
return
render_template
(
'
not_implemented.html
'
)
return
render_template
(
'
org_submit_list.html
'
,
sc
=
sc
,
sol
=
sol
,
sol_papers
=
sol_papers
,
fb_papers
=
fb_papers
,
for_site
=
(
site_id
is
not
None
),
)
@app.route
(
'
/org/contest/c/<int:contest_id>/paper/<int:paper_id>/
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/site/<int:site_id>/paper/<int:paper_id>/
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/site/<int:site_id>/paper/<int:paper_id>/
'
)
def
org_submit_site_paper
(
contest_id
,
paper_id
):
def
org_submit_paper
(
contest_id
:
int
,
paper_id
:
int
,
site_id
:
Optional
[
int
]
=
None
):
# sc = get_solution_context(contest_id, None, user_id, task_id)
paper
=
(
db
.
get_session
().
query
(
db
.
Paper
)
.
options
(
joinedload
(
db
.
Paper
.
task
))
# pro send_task_paper()
.
get
(
paper_id
))
if
not
paper
:
raise
werkzeug
.
exceptions
.
NotFound
()
# FIXME
get_solution_context
(
contest_id
,
paper
.
for_user
,
paper
.
for_task
,
site_id
)
return
render_template
(
'
not_implemented.html
'
)
return
mo
.
web
.
util
.
send_task_paper
(
paper
)
@app.route
(
'
/org/contest/c/<int:id>/proctor-import
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
@app.route
(
'
/org/contest/c/<int:id>/proctor-import
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
...
...
This diff is collapsed.
Click to expand it.
mo/web/util.py
+
1
−
0
View file @
c9956d4e
...
@@ -62,6 +62,7 @@ def send_task_paper(paper: db.Paper) -> Response:
...
@@ -62,6 +62,7 @@ def send_task_paper(paper: db.Paper) -> Response:
else
:
else
:
assert
False
assert
False
# FIXME: Předání jména funguje jen s as_attachment=True
if
os
.
path
.
isfile
(
file
):
if
os
.
path
.
isfile
(
file
):
return
send_file
(
file
,
return
send_file
(
file
,
mimetype
=
'
application/pdf
'
,
mimetype
=
'
application/pdf
'
,
...
...
This diff is collapsed.
Click to expand it.
static/mo.css
+
6
−
0
View file @
c9956d4e
...
@@ -121,3 +121,9 @@ nav#main-menu a.active {
...
@@ -121,3 +121,9 @@ nav#main-menu a.active {
.rstate-closed
{
.rstate-closed
{
color
:
black
;
color
:
black
;
}
}
/* Solutions */
.sol-active
{
background-color
:
yellow
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment