Skip to content
Snippets Groups Projects
Commit c9956d4e authored by Martin Mareš's avatar Martin Mareš
Browse files

Přehled odevzdaných řešení a feedbacků účastníka + jejich stahování

parent e8fbdb2f
Branches
No related tags found
1 merge request!9WIP: Zárodek uživatelské části webu a submitování
......@@ -19,6 +19,7 @@ import mo.rights
from mo.rights import Right, Rights
import mo.util
from mo.web import app
import mo.web.util
from mo.web.util import PagerForm
from mo.web.table import CellCheckbox, Table, Column, cell_place_link, cell_user_link, cell_email_link
import wtforms.validators as validators
......@@ -451,14 +452,14 @@ class SolutionContext:
contest: db.Contest
round: db.Round
pion: db.Participation
user: db.User
task: db.Task
solution: Optional[db.Solution]
allow_view: bool
allow_upload_solutions: 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()
# Nejprve zjistíme, zda existuje soutěž
......@@ -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
pion = (sess.query(db.Participation)
.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())
if not pion:
raise werkzeug.exceptions.NotFound()
......@@ -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
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()
# 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
if site_id is not None:
site = pion.place
......@@ -510,8 +507,8 @@ def get_solution_context(contest_id: int, site_id: Optional[int], user_id: int,
contest=contest,
round=round,
pion=pion,
user=pion.user,
task=task,
solution=sol,
allow_view=allow_view,
allow_upload_solutions=allow_upload_solutions,
allow_upload_feedback=allow_upload_feedback,
......@@ -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>/')
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>/')
def org_submit_site_list(contest_id, site_id, user_id, task_id):
sc = get_solution_context(contest_id, site_id, user_id, task_id)
# FIXME
return render_template('not_implemented.html')
def org_submit_list(contest_id: int, user_id: int, task_id: int, site_id: Optional[int] = None):
sc = get_solution_context(contest_id, user_id, task_id, site_id)
# 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>/')
def org_submit_paper(contest_id, paper_id):
# sc = get_solution_context(contest_id, None, user_id, task_id)
papers = (db.get_session().query(db.Paper)
.filter_by(for_user_obj=sc.user, task=sc.task)
.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>/')
def org_submit_site_paper(contest_id, paper_id):
# sc = get_solution_context(contest_id, None, user_id, task_id)
def org_submit_paper(contest_id: int, paper_id: int, site_id: Optional[int] = None):
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'))
......
......@@ -62,6 +62,7 @@ def send_task_paper(paper: db.Paper) -> Response:
else:
assert False
# FIXME: Předání jména funguje jen s as_attachment=True
if os.path.isfile(file):
return send_file(file,
mimetype='application/pdf',
......
......@@ -121,3 +121,9 @@ nav#main-menu a.active {
.rstate-closed {
color: black;
}
/* Solutions */
.sol-active {
background-color: yellow;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment