362
363
<h2>Worksheet Contents</h2>
367
for tag, xml in find_all_nodes(req, node):
370
# Fragment ID is an accumulating exerciseid
371
# (The same algorithm is employed when presenting exercises)
372
fragment_id = "exercise%d" % exerciseid
374
exercisesrc = xml.getAttribute("src")
375
# Optionality: Defaults to False
376
exerciseoptional = xml.getAttribute("optional") == "true"
377
# Record the name and optionality for returning in the list
378
exercise_list.append((exercisesrc, exerciseoptional))
379
# TODO: Get proper exercise title
381
# Get the completion status of this exercise
382
complete, _ = db.get_problem_status(req.user.login,
384
req.write(' <li class="%s" id="toc_li_%s"><a href="#%s">%s'
386
% ("complete" if complete else "incomplete",
387
fragment_id, fragment_id, cgi.escape(title)))
390
fragment_id = getID(xml)
391
title = getTextData(xml)
392
req.write(' <li><a href="#%s">%s</a></li>\n'
393
% (fragment_id, cgi.escape(title)))
366
for tag, xml in find_all_nodes(req, node):
369
# Fragment ID is an accumulating exerciseid
370
# (The same algorithm is employed when presenting exercises)
371
fragment_id = "exercise%d" % exerciseid
373
exercisesrc = xml.getAttribute("src")
374
# Optionality: Defaults to False
375
exerciseoptional = xml.getAttribute("optional") == "true"
376
# Record the name and optionality for returning in the list
377
exercise_list.append((exercisesrc, exerciseoptional))
378
# TODO: Get proper exercise title
380
# Get the completion status of this exercise
381
exercise = ivle.database.Exercise.get_by_name(req.store,
383
complete, _ = ivle.worksheet.get_exercise_status(req.store,
385
req.write(' <li class="%s" id="toc_li_%s"><a href="#%s">%s'
387
% ("complete" if complete else "incomplete",
388
fragment_id, fragment_id, cgi.escape(title)))
391
fragment_id = getID(xml)
392
title = getTextData(xml)
393
req.write(' <li><a href="#%s">%s</a></li>\n'
394
% (fragment_id, cgi.escape(title)))
396
395
req.write('</ul>\n</div>\n')
397
396
return exercise_list
535
535
saved_text = db.get_problem_stored_text(login=req.user.login,
536
536
exercisename=exercisesrc)
537
# Also get the number of attempts taken and whether this is complete.
538
complete, attempts = db.get_problem_status(login=req.user.login,
539
exercisename=exercisesrc)
539
# Also get the number of attempts taken and whether this is complete.
540
complete, attempts = ivle.worksheet.get_exercise_status(req.store,
542
542
if saved_text is not None:
543
543
# Important: We got the string from the DB encoded in UTF-8
544
544
# Make it a unicode string.