~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/tutorial/__init__.py

  • Committer: Matt Giuca
  • Date: 2009-01-19 16:20:55 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: matt.giuca@gmail.com-20090119162055-z8m5kziajg5hchi6
ivle.worksheet: Added get_exercise_stored_text, ported from
    ivle.db.get_problem_stored_text, to Storm.

    Golly jeepers, the code is so nice with an ORM :)

ivle.db: Removed get_problem_stored_text.

tutorial: Updated to use get_exercise_stored_text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
529
529
 
530
530
    # If the user has already saved some text for this problem, or submitted
531
531
    # an attempt, then use that text instead of the supplied "partial".
532
 
    saved_text = None
533
 
    db = ivle.db.DB()
534
 
    try:
535
 
        saved_text = db.get_problem_stored_text(login=req.user.login,
536
 
            exercisename=exercisesrc)
537
 
    finally:
538
 
        db.close()
 
532
    saved_text = ivle.worksheet.get_exercise_stored_text(req.store,
 
533
        req.user, exercise)
539
534
    # Also get the number of attempts taken and whether this is complete.
540
535
    complete, attempts = ivle.worksheet.get_exercise_status(req.store,
541
536
        req.user, exercise)
542
537
    if saved_text is not None:
543
 
        # Important: We got the string from the DB encoded in UTF-8
544
 
        # Make it a unicode string.
545
 
        exercisepartial = saved_text.decode('utf-8')
 
538
        exercisepartial = saved_text.text
546
539
 
547
540
    # Print this exercise out to HTML 
548
541
    req.write("<p><b>Exercise:</b> %s</p>\n" % cgi.escape(exercisename))