Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cms/server/admin/handlers/contestquestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
collections.MutableMapping = collections.abc.MutableMapping

import tornado.web
from sqlalchemy import case

from cms.db import Contest, Question, Participation
from cmscommon.datetime import make_datetime
Expand All @@ -53,10 +54,20 @@ class QuestionsHandler(BaseHandler):
def get(self, contest_id):
self.contest = self.safe_get_item(Contest, contest_id)

answered = case(
[(
(Question.reply_timestamp.is_(None)) &
(Question.ignored.is_(False)),
0
)],
else_=1
)

self.r_params = self.render_params()
self.r_params["questions"] = self.sql_session.query(Question)\
.join(Participation)\
.filter(Participation.contest_id == contest_id)\
.order_by(answered)\
.order_by(Question.question_timestamp.desc())\
.order_by(Question.id).all()
self.render("questions.html", **self.r_params)
Expand Down
Loading