Commit be5e84ef authored by Martin Mareš's avatar Martin Mareš
Browse files

Copy: Choice from last 2 semesters

parent 13840363
......@@ -1280,19 +1280,17 @@ def admin_edit_topic(sident, cident, tid=None, copy_tid=None):
def course_choices(include_tid):
db_query("SELECT * FROM owl_semesters ORDER BY rank DESC LIMIT 1")
semester_row = db.fetchone()
if not semester_row:
return []
db_query("SELECT semid FROM owl_semesters ORDER BY rank DESC LIMIT 2")
sem_ids = tuple(db.fetchall())
db_query("""
SELECT c.cid, s.ident AS sident, c.ident AS cident, c.name
FROM owl_courses c
JOIN owl_semesters s USING(semid)
JOIN owl_enroll e USING(cid)
WHERE (c.semid=%s OR c.cid=%s) AND e.uid=%s AND e.is_teacher=true
WHERE (c.semid IN %s OR c.cid=%s) AND e.uid=%s AND e.is_teacher=true
ORDER BY s.rank DESC, c.ident
""", (semester_row.semid, include_tid, g.uid))
""", (sem_ids, include_tid, g.uid))
choices = []
for c in db.fetchall():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment