#!/usr/bin/python # CodeQ: an online programming tutor. # Copyright (C) 2015 UL FRI # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import sys from server.problems import load_problem if len(sys.argv) < 5: sys.stderr.write('usage: {} programming_language group problem language\n'.format(sys.argv[0])) sys.exit(1) language, group, problem, tail = sys.argv[1:] mod = load_problem(language, group, problem, tail) print('''\ Problem ''') print('

{}

'.format(mod.name)) print('{}'.format(mod.description)) print('
') print('

Plan

') for n, plan in enumerate(mod.plan): print('
') print('

Plan #{}

'.format(n)) if isinstance(plan, list): for i, p_part in enumerate(plan): if isinstance(p_part, dict): p_part = p_part['message'] print(p_part) if i < len(plan)-1: print('
') else: print(plan) print('
') print('
') print('
') print('

Hints

') for id, hint in sorted(mod.hint.items()): print('
') print('

{}

'.format(id)) if isinstance(hint, list): for i, hint_part in enumerate(hint): if isinstance(hint_part, dict): hint_part = hint_part['message'] print(hint_part) if i < len(hint)-1: print('
') else: print(hint) print('
') print('
') print('''\ ''')