From 9b0915cb2ac613d2da04381772f2bf840f99068b Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 5 Nov 2015 14:51:03 +0100 Subject: Add a script to generate HTML with problem description --- scripts/problem_html.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 scripts/problem_html.py (limited to 'scripts') diff --git a/scripts/problem_html.py b/scripts/problem_html.py new file mode 100644 index 0000000..4d71b18 --- /dev/null +++ b/scripts/problem_html.py @@ -0,0 +1,78 @@ +#!/usr/bin/python + +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('''\ + +''') -- cgit v1.2.1