Commit 3f0b10f39413035370ebc5fc691902518775e84a
1 parent
7649945c
Exists in
master
and in
1 other branch
- added show_ref flag so that question ref and filename are shown.
Showing
4 changed files
with
27 additions
and
8 deletions
Show diff stats
MANUAL.md
@@ -95,7 +95,10 @@ A test is a file in `yaml` format that can reside anywhere on the filesystem. It | @@ -95,7 +95,10 @@ A test is a file in `yaml` format that can reside anywhere on the filesystem. It | ||
95 | practice_mode: True | 95 | practice_mode: True |
96 | 96 | ||
97 | # Show the data structures obtained from the test and the questions | 97 | # Show the data structures obtained from the test and the questions |
98 | - debug: True | 98 | + debug: False |
99 | + | ||
100 | + # Show the file and ref field of each question | ||
101 | + show_ref: True | ||
99 | 102 | ||
100 | # ------------------------------------------------------------------------- | 103 | # ------------------------------------------------------------------------- |
101 | # This are the questions database to be imported. | 104 | # This are the questions database to be imported. |
serve.py
@@ -146,6 +146,8 @@ def parse_arguments(): | @@ -146,6 +146,8 @@ def parse_arguments(): | ||
146 | argparser.add_argument('--server', default='conf/server.conf', type=str, help='server configuration file') | 146 | argparser.add_argument('--server', default='conf/server.conf', type=str, help='server configuration file') |
147 | argparser.add_argument('--debug', action='store_true', | 147 | argparser.add_argument('--debug', action='store_true', |
148 | help='Show datastructures when rendering questions') | 148 | help='Show datastructures when rendering questions') |
149 | + argparser.add_argument('--show_ref', action='store_true', | ||
150 | + help='Show filename and ref field for each question') | ||
149 | argparser.add_argument('--show_points', action='store_true', | 151 | argparser.add_argument('--show_points', action='store_true', |
150 | help='Show normalized points for each question') | 152 | help='Show normalized points for each question') |
151 | argparser.add_argument('--show_hints', action='store_true', | 153 | argparser.add_argument('--show_hints', action='store_true', |
@@ -161,7 +163,7 @@ def parse_arguments(): | @@ -161,7 +163,7 @@ def parse_arguments(): | ||
161 | if __name__ == '__main__': | 163 | if __name__ == '__main__': |
162 | # --- parse command line arguments and build base test | 164 | # --- parse command line arguments and build base test |
163 | arg = parse_arguments() | 165 | arg = parse_arguments() |
164 | - testconf = test.read_configuration(arg.testfile[0], debug=arg.debug, show_points=arg.show_points, show_hints=arg.show_hints, save_answers=arg.save_answers, practice=arg.practice) | 166 | + testconf = test.read_configuration(arg.testfile[0], debug=arg.debug, show_points=arg.show_points, show_hints=arg.show_hints, save_answers=arg.save_answers, practice=arg.practice, show_ref=arg.show_ref) |
165 | 167 | ||
166 | print('=' * 79) | 168 | print('=' * 79) |
167 | print('- Title: %s' % testconf['title']) | 169 | print('- Title: %s' % testconf['title']) |
templates/test.html
@@ -157,7 +157,7 @@ | @@ -157,7 +157,7 @@ | ||
157 | Classificar | 157 | Classificar |
158 | </div> | 158 | </div> |
159 | <div class="panel-body" id="example${i}"> | 159 | <div class="panel-body" id="example${i}"> |
160 | - <h4> ${i+1}.</h4> | 160 | + <h4> ${i+1}. </h4> |
161 | 161 | ||
162 | <p class="question"> | 162 | <p class="question"> |
163 | ${pretty(q['text'])} | 163 | ${pretty(q['text'])} |
@@ -253,11 +253,24 @@ | @@ -253,11 +253,24 @@ | ||
253 | % endif | 253 | % endif |
254 | 254 | ||
255 | </div> <!-- panel-body --> | 255 | </div> <!-- panel-body --> |
256 | - % if t['debug']: | 256 | + % if t['debug'] or t['show_ref']: |
257 | <div class="panel-footer"> | 257 | <div class="panel-footer"> |
258 | - <pre> | ||
259 | - ${yaml.dump(q)} | ||
260 | - </pre> | 258 | + |
259 | + % if t['debug']: | ||
260 | + <pre> | ||
261 | + ${yaml.dump(q)} | ||
262 | + </pre> | ||
263 | + % endif | ||
264 | + | ||
265 | + % if t['show_ref']: | ||
266 | + <dl class="dl-horizontal"> | ||
267 | + <dt>filename:</dt> | ||
268 | + <dd>${q['filename']}</dd> | ||
269 | + <dt>ref:</dt> | ||
270 | + <dd>${q['ref']}</dd> | ||
271 | + </dl> | ||
272 | + % endif | ||
273 | + | ||
261 | </div> | 274 | </div> |
262 | % endif | 275 | % endif |
263 | </div> <!-- panel --> | 276 | </div> <!-- panel --> |
test.py
@@ -11,7 +11,7 @@ import questions | @@ -11,7 +11,7 @@ import questions | ||
11 | import database | 11 | import database |
12 | 12 | ||
13 | # =========================================================================== | 13 | # =========================================================================== |
14 | -def read_configuration(filename, debug=False, show_points=False, show_hints=False, practice=False, save_answers=False): | 14 | +def read_configuration(filename, debug=False, show_points=False, show_hints=False, practice=False, save_answers=False, show_ref=False): |
15 | # FIXME validar se ficheiros e directorios existem??? | 15 | # FIXME validar se ficheiros e directorios existem??? |
16 | if not os.path.isfile(filename): | 16 | if not os.path.isfile(filename): |
17 | print('Cannot find file "%s"' % filename) | 17 | print('Cannot find file "%s"' % filename) |
@@ -31,6 +31,7 @@ def read_configuration(filename, debug=False, show_points=False, show_hints=Fals | @@ -31,6 +31,7 @@ def read_configuration(filename, debug=False, show_points=False, show_hints=Fals | ||
31 | test['show_points'] = bool(test.get('show_points', show_points)) | 31 | test['show_points'] = bool(test.get('show_points', show_points)) |
32 | test['practice'] = bool(test.get('practice', practice)) | 32 | test['practice'] = bool(test.get('practice', practice)) |
33 | test['debug'] = bool(test.get('debug', debug)) | 33 | test['debug'] = bool(test.get('debug', debug)) |
34 | + test['show_ref'] = bool(test.get('show_ref', show_ref)) | ||
34 | test['save_answers'] = bool(test.get('save_answers', save_answers)) | 35 | test['save_answers'] = bool(test.get('save_answers', save_answers)) |
35 | if test['save_answers']: | 36 | if test['save_answers']: |
36 | if 'answers_dir' not in test: | 37 | if 'answers_dir' not in test: |