199
199
worksheetdom.getAttribute("name"))
200
200
worksheets.append(worksheet)
202
# Now all the errors are out the way, we can begin writing
203
req.title = "Tutorial - %s" % subject
204
req.write_html_head_foot = True
205
req.write('<div id="ivle_padding">\n')
206
req.write("<h1>IVLE Tutorials - %s</h1>\n" % cgi.escape(subject))
207
req.write("<h2>Worksheets</h2>\n<ul>\n")
208
for worksheet in worksheets:
209
req.write(' <li><a href="%s">%s</a></li>\n'
210
% (urllib.quote(worksheet.id), cgi.escape(worksheet.name)))
212
req.write("</div>\n") # tutorialbody
204
# Now all the errors are out the way, we can begin writing
205
req.title = "Tutorial - %s" % subject
206
req.write_html_head_foot = True
207
req.write('<div id="ivle_padding">\n')
208
req.write("<h1>IVLE Tutorials - %s</h1>\n" % cgi.escape(subject))
209
req.write('<h2>Worksheets</h2>\n<ul id="tutorial-toc">\n')
210
# As we go, calculate the total score for this subject
211
# (Assessable worksheets only, mandatory problems only)
214
for worksheet in worksheets:
215
req.write(' <li><a href="%s">%s</a>'
216
% (urllib.quote(worksheet.id), cgi.escape(worksheet.name)))
218
if db.worksheet_is_assessable(subject, worksheet.id):
219
mand_done, mand_total, opt_done, opt_total = (
220
db.calculate_score_worksheet(req.user.login, subject,
223
optional_message = " (excluding optional exercises)"
225
optional_message = ""
226
if mand_done >= mand_total:
227
complete_class = "complete"
229
complete_class = "semicomplete"
231
complete_class = "incomplete"
232
problems_done += mand_done
233
problems_total += mand_total
234
req.write('\n <ul><li class="%s">'
235
'Completed %d/%d%s</li></ul>\n '
236
% (complete_class, mand_done, mand_total,
238
except common.db.DBException:
239
# Worksheet is probably not in database yet
243
if problems_total > 0:
244
if problems_done >= problems_total:
245
complete_class = "complete"
246
elif problems_done > 0:
247
complete_class = "semicomplete"
249
complete_class = "incomplete"
250
problems_pct = (100 * problems_done) / problems_total # int
251
req.write('<ul><li class="%s">Total exercises completed: %d/%d '
253
% (complete_class, problems_done, problems_total,
255
req.write("</div>\n") # tutorialbody
214
259
def handle_worksheet(req, subject, worksheet):
215
260
# Subject and worksheet names must be valid identifiers