Commit 3f0b10f39413035370ebc5fc691902518775e84a

Authored by Miguel Barao
1 parent 7649945c
Exists in master and in 1 other branch dev

- added show_ref flag so that question ref and filename are shown.

MANUAL.md
... ... @@ -95,7 +95,10 @@ A test is a file in `yaml` format that can reside anywhere on the filesystem. It
95 95 practice_mode: True
96 96  
97 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 104 # This are the questions database to be imported.
... ...
serve.py
... ... @@ -146,6 +146,8 @@ def parse_arguments():
146 146 argparser.add_argument('--server', default='conf/server.conf', type=str, help='server configuration file')
147 147 argparser.add_argument('--debug', action='store_true',
148 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 151 argparser.add_argument('--show_points', action='store_true',
150 152 help='Show normalized points for each question')
151 153 argparser.add_argument('--show_hints', action='store_true',
... ... @@ -161,7 +163,7 @@ def parse_arguments():
161 163 if __name__ == '__main__':
162 164 # --- parse command line arguments and build base test
163 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 168 print('=' * 79)
167 169 print('- Title: %s' % testconf['title'])
... ...
templates/test.html
... ... @@ -157,7 +157,7 @@
157 157  Classificar
158 158 </div>
159 159 <div class="panel-body" id="example${i}">
160   - <h4> ${i+1}.</h4>
  160 + <h4> ${i+1}. </h4>
161 161  
162 162 <p class="question">
163 163 ${pretty(q['text'])}
... ... @@ -253,11 +253,24 @@
253 253 % endif
254 254  
255 255 </div> <!-- panel-body -->
256   - % if t['debug']:
  256 + % if t['debug'] or t['show_ref']:
257 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 274 </div>
262 275 % endif
263 276 </div> <!-- panel -->
... ...
test.py
... ... @@ -11,7 +11,7 @@ import questions
11 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 15 # FIXME validar se ficheiros e directorios existem???
16 16 if not os.path.isfile(filename):
17 17 print('Cannot find file "%s"' % filename)
... ... @@ -31,6 +31,7 @@ def read_configuration(filename, debug=False, show_points=False, show_hints=Fals
31 31 test['show_points'] = bool(test.get('show_points', show_points))
32 32 test['practice'] = bool(test.get('practice', practice))
33 33 test['debug'] = bool(test.get('debug', debug))
  34 + test['show_ref'] = bool(test.get('show_ref', show_ref))
34 35 test['save_answers'] = bool(test.get('save_answers', save_answers))
35 36 if test['save_answers']:
36 37 if 'answers_dir' not in test:
... ...